mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-23 15:34:34 +00:00
Merge pull request #541 from avao/master
UT and Fix for: Index out of range exception from gzip #532
This commit is contained in:
@@ -384,16 +384,7 @@ namespace SharpCompress.Compressors.Deflate
|
||||
if (_fileName.Contains("\\"))
|
||||
{
|
||||
// trim any leading path
|
||||
int length = _fileName.Length;
|
||||
int num = length;
|
||||
while (--num >= 0)
|
||||
{
|
||||
char c = _fileName[num];
|
||||
if (c == '\\')
|
||||
{
|
||||
_fileName = _fileName.Substring(num + 1, length - num - 1);
|
||||
}
|
||||
}
|
||||
_fileName = Path.GetFileName(_fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,5 +49,18 @@ namespace SharpCompress.Test.GZip
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GZip_Writer_Entry_Path_With_Dir()
|
||||
{
|
||||
using (Stream stream = File.Open(Path.Combine(SCRATCH_FILES_PATH, "Tar.tar.gz"), FileMode.OpenOrCreate, FileAccess.Write))
|
||||
using (var writer = new GZipWriter(stream))
|
||||
{
|
||||
var path = Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar");
|
||||
writer.Write(path, path); //covers issue #532
|
||||
}
|
||||
CompareArchivesByPath(Path.Combine(SCRATCH_FILES_PATH, "Tar.tar.gz"),
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar.gz"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user