-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Steps to reproduce
- Create package using the below methods.
public static void CreateTarGZ(string tgzFilename, string sourceDirectory)
{
Stream outStream = File.Create(tgzFilename);
var gzoStream = new GZipOutputStream(outStream);
gzoStream.SetLevel(0);
TarArchive tarArchive = TarArchive.CreateOutputTarArchive(gzoStream);
// Note that the RootPath is currently case sensitive and must be forward slashes e.g. "c:/temp"
// and must not end with a slash, otherwise cuts off first char of filename
// This is scheduled for fix in next release
tarArchive.RootPath = sourceDirectory.Replace("\\\\", "/");
if (tarArchive.RootPath.EndsWith("/"))
tarArchive.RootPath = tarArchive.RootPath.Remove(tarArchive.RootPath.Length - 1);
AddDirectoryFilesToTar(tarArchive, sourceDirectory, true, true);
tarArchive.Close();
}
private static void AddDirectoryFilesToTar(TarArchive tarArchive, string sourceDirectory, bool recurse, bool isRoot)
{
// Optionally, write an entry for the directory itself.
// Specify false for recursion here if we will add the directory's files individually.
TarEntry tarEntry;
if (!isRoot)
{
tarEntry = TarEntry.CreateEntryFromFile(sourceDirectory);
tarArchive.WriteEntry(tarEntry, false);
}
// Write each file to the tar.
string[] filenames = Directory.GetFiles(sourceDirectory);
foreach (string filename in filenames)
{
if (!filename.EndsWith(".gz"))
{
Console.WriteLine($"Adding {filename}...");
tarEntry = TarEntry.CreateEntryFromFile(filename);
tarArchive.WriteEntry(tarEntry, true);
}
}
if (recurse)
{
string[] directories = Directory.GetDirectories(sourceDirectory);
foreach (string directory in directories)
AddDirectoryFilesToTar(tarArchive, directory, recurse, false);
}
}- Run windows tar.exe command from commandprompt : tar -xvf [nameOfTar].tar.gz
Expected behavior
The tar.exe should not report any errors.
Actual behavior
tar.exe returns this error : tar: Archive entry has empty or unreadable filename ... skipping.
Version of SharpZipLib
1.3.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels