コード例 #1
0
ファイル: TarballProject.cs プロジェクト: fundies/Aegisub
        private void ExtractEntry(string destDir, TarEntry entry, ICSharpCode.SharpZipLib.Tar.TarInputStream stream) {
            string name = entry.Name;
            if (Path.IsPathRooted(name))
                name = name.Substring(Path.GetPathRoot(name).Length);
            name = name.Replace('/', Path.DirectorySeparatorChar);
            name = name.Substring(name.IndexOf(Path.DirectorySeparatorChar) + 1);

            string dest = Path.Combine(destDir, name);
            if (entry.IsDirectory)
                Directory.CreateDirectory(dest);
            else {
                Directory.CreateDirectory(Path.GetDirectoryName(dest));
                using (Stream outputStream = File.Create(dest)) {
                    stream.CopyEntryContents(outputStream);
                }
            }
        }