Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ DoCreateFromDirectory()

static void System.IO.Compression.ZipFile.DoCreateFromDirectory ( string sourceDirectoryName,
string destinationArchiveFileName,
CompressionLevel? compressionLevel,
bool includeBaseDirectory,
Encoding entryNameEncoding )
inlinestaticprivate

Definition at line 70 of file ZipFile.cs.

71 {
72 sourceDirectoryName = Path.GetFullPath(sourceDirectoryName);
73 destinationArchiveFileName = Path.GetFullPath(destinationArchiveFileName);
74 using ZipArchive zipArchive = Open(destinationArchiveFileName, ZipArchiveMode.Create, entryNameEncoding);
75 bool flag = true;
76 DirectoryInfo directoryInfo = new DirectoryInfo(sourceDirectoryName);
77 string fullName = directoryInfo.FullName;
78 if (includeBaseDirectory && directoryInfo.Parent != null)
79 {
80 fullName = directoryInfo.Parent.FullName;
81 }
82 char[] buffer = ArrayPool<char>.Shared.Rent(260);
83 try
84 {
85 foreach (FileSystemInfo item in directoryInfo.EnumerateFileSystemInfos("*", SearchOption.AllDirectories))
86 {
87 flag = false;
88 int length = item.FullName.Length - fullName.Length;
89 if (item is FileInfo)
90 {
91 string entryName = ZipFileUtils.EntryFromPath(item.FullName, fullName.Length, length, ref buffer);
92 zipArchive.DoCreateEntryFromFile(item.FullName, entryName, compressionLevel);
93 }
94 else if (item is DirectoryInfo possiblyEmptyDir && ZipFileUtils.IsDirEmpty(possiblyEmptyDir))
95 {
96 string entryName2 = ZipFileUtils.EntryFromPath(item.FullName, fullName.Length, length, ref buffer, appendPathSeparator: true);
97 zipArchive.CreateEntry(entryName2);
98 }
99 }
100 if (includeBaseDirectory && flag)
101 {
102 zipArchive.CreateEntry(ZipFileUtils.EntryFromPath(directoryInfo.Name, 0, directoryInfo.Name.Length, ref buffer, appendPathSeparator: true));
103 }
104 }
105 finally
106 {
108 }
109 }
static ArrayPool< T > Shared
Definition ArrayPool.cs:7

References System.buffer, System.IO.Compression.ZipFileUtils.EntryFromPath(), System.IO.DirectoryInfo.EnumerateFileSystemInfos(), System.IO.FileSystemInfo.FullName, System.IO.Path.GetFullPath(), System.IO.Compression.ZipFileUtils.IsDirEmpty(), System.item, System.length, System.IO.FileSystemInfo.Name, System.IO.Open, System.IO.DirectoryInfo.Parent, and System.Buffers.ArrayPool< T >.Shared.

Referenced by System.IO.Compression.ZipFile.CreateFromDirectory(), System.IO.Compression.ZipFile.CreateFromDirectory(), and System.IO.Compression.ZipFile.CreateFromDirectory().