/// <summary> /// Write an entry to the archive. This method will call the putNextEntry /// and then write the contents of the entry, and finally call closeEntry() /// for entries that are files. For directories, it will call putNextEntry(), /// and then, if the recurse flag is true, process each entry that is a /// child of the directory. /// </summary> /// <param name="sourceEntry"> /// The TarEntry representing the entry to write to the archive. /// </param> /// <param name="recurse"> /// If true, process the children of directory entries. /// </param> void InternalWriteEntry(TarEntry sourceEntry, bool recurse) { var asciiTrans = false; string tempFileName = null; var entryFilename = sourceEntry.File; var entry = (TarEntry)sourceEntry.Clone(); if (applyUserInfoOverrides) { entry.GroupId = groupId; entry.GroupName = groupName; entry.UserId = userId; entry.UserName = userName; } OnProgressMessageEvent(entry, null); if (asciiTranslate && !entry.IsDirectory) { asciiTrans = !IsBinary(entryFilename); if (asciiTrans) { tempFileName = Path.GetTempFileName(); var inStream = File.OpenText(entryFilename); Stream outStream = File.Create(tempFileName); while (true) { var line = inStream.ReadLine(); if (line == null) { break; } var data = Encoding.ASCII.GetBytes(line); outStream.Write(data, 0, data.Length); outStream.WriteByte((byte)'\n'); } inStream.Close(); outStream.Flush(); outStream.Close(); entry.Size = new FileInfo(tempFileName).Length; entryFilename = tempFileName; } } string newName = null; if (rootPath != null) { if (entry.Name.StartsWith(rootPath)) { newName = entry.Name.Substring(rootPath.Length + 1); } } if (pathPrefix != null) { newName = (newName == null) ? pathPrefix + "/" + entry.Name : pathPrefix + "/" + newName; } if (newName != null) { entry.Name = newName; } tarOut.PutNextEntry(entry); if (entry.IsDirectory) { if (recurse) { var list = entry.GetDirectoryEntries(); for (var i = 0; i < list.Length; ++i) { InternalWriteEntry(list[i], recurse); } } } else { Stream inputStream = File.OpenRead(entryFilename); var numWritten = 0; var eBuf = new byte[32 * 1024]; while (true) { var numRead = inputStream.Read(eBuf, 0, eBuf.Length); if (numRead <= 0) { break; } tarOut.Write(eBuf, 0, numRead); numWritten += numRead; } inputStream.Close(); if (tempFileName != null && tempFileName.Length > 0) { File.Delete(tempFileName); } tarOut.CloseEntry(); } }
/// <summary> /// Write an entry to the archive. This method will call the putNextEntry /// and then write the contents of the entry, and finally call closeEntry() /// for entries that are files. For directories, it will call putNextEntry(), /// and then, if the recurse flag is true, process each entry that is a /// child of the directory. /// </summary> /// <param name="sourceEntry"> /// The TarEntry representing the entry to write to the archive. /// </param> /// <param name="recurse"> /// If true, process the children of directory entries. /// </param> void WriteEntryCore(TarEntry sourceEntry, bool recurse) { string tempFileName = null; string entryFilename = sourceEntry.File; TarEntry entry = (TarEntry)sourceEntry.Clone(); if ( applyUserInfoOverrides ) { entry.GroupId = groupId; entry.GroupName = groupName; entry.UserId = userId; entry.UserName = userName; } OnProgressMessageEvent(entry, null); if (asciiTranslate && !entry.IsDirectory) { if (!IsBinary(entryFilename)) { tempFileName = Path.GetTempFileName(); using (StreamReader inStream = File.OpenText(entryFilename)) { using (Stream outStream = File.Create(tempFileName)) { while (true) { string line = inStream.ReadLine(); if (line == null) { break; } byte[] data = Encoding.ASCII.GetBytes(line); outStream.Write(data, 0, data.Length); outStream.WriteByte((byte)'\n'); } outStream.Flush(); } } entry.Size = new FileInfo(tempFileName).Length; entryFilename = tempFileName; } } string newName = null; if (rootPath != null) { if (entry.Name.StartsWith(rootPath, StringComparison.OrdinalIgnoreCase)) { newName = entry.Name.Substring(rootPath.Length + 1 ); } } if (pathPrefix != null) { newName = (newName == null) ? pathPrefix + "/" + entry.Name : pathPrefix + "/" + newName; } if (newName != null) { entry.Name = newName; } tarOut.PutNextEntry(entry); if (entry.IsDirectory) { if (recurse) { TarEntry[] list = entry.GetDirectoryEntries(); for (int i = 0; i < list.Length; ++i) { WriteEntryCore(list[i], recurse); } } } else { using (Stream inputStream = File.OpenRead(entryFilename)) { byte[] localBuffer = new byte[32 * 1024]; while (true) { int numRead = inputStream.Read(localBuffer, 0, localBuffer.Length); if (numRead <=0) { break; } tarOut.Write(localBuffer, 0, numRead); } } if ( (tempFileName != null) && (tempFileName.Length > 0) ) { File.Delete(tempFileName); } tarOut.CloseEntry(); } }
private void WriteEntryCore(TarEntry sourceEntry, bool recurse) { string text = null; string text2 = sourceEntry.File; TarEntry tarEntry = (TarEntry)sourceEntry.Clone(); if (applyUserInfoOverrides) { tarEntry.GroupId = groupId; tarEntry.GroupName = groupName; tarEntry.UserId = userId; tarEntry.UserName = userName; } OnProgressMessageEvent(tarEntry, null); if (asciiTranslate && !tarEntry.IsDirectory && !IsBinary(text2)) { text = Path.GetTempFileName(); using (StreamReader streamReader = File.OpenText(text2)) { using (Stream stream = File.Create(text)) { while (true) { string text3 = streamReader.ReadLine(); if (text3 == null) { break; } byte[] bytes = Encoding.ASCII.GetBytes(text3); stream.Write(bytes, 0, bytes.Length); stream.WriteByte(10); } stream.Flush(); } } tarEntry.Size = new FileInfo(text).Length; text2 = text; } string text4 = null; if (rootPath != null && tarEntry.Name.StartsWith(rootPath)) { text4 = tarEntry.Name.Substring(rootPath.Length + 1); } if (pathPrefix != null) { text4 = ((text4 == null) ? (pathPrefix + "/" + tarEntry.Name) : (pathPrefix + "/" + text4)); } if (text4 != null) { tarEntry.Name = text4; } tarOut.PutNextEntry(tarEntry); if (tarEntry.IsDirectory) { if (recurse) { TarEntry[] directoryEntries = tarEntry.GetDirectoryEntries(); for (int i = 0; i < directoryEntries.Length; i++) { WriteEntryCore(directoryEntries[i], recurse); } } } else { using (Stream stream2 = File.OpenRead(text2)) { byte[] array = new byte[32768]; while (true) { int num = stream2.Read(array, 0, array.Length); if (num <= 0) { break; } tarOut.Write(array, 0, num); } } if (text != null && text.Length > 0) { File.Delete(text); } tarOut.CloseEntry(); } }
/// <summary> /// Write an entry to the archive. This method will call the putNextEntry /// and then write the contents of the entry, and finally call closeEntry() /// for entries that are files. For directories, it will call putNextEntry(), /// and then, if the recurse flag is true, process each entry that is a /// child of the directory. /// </summary> /// <param name="sourceEntry"> /// The TarEntry representing the entry to write to the archive. /// </param> /// <param name="recurse"> /// If true, process the children of directory entries. /// </param> void WriteEntryCore(TarEntry sourceEntry, bool recurse) { string tempFileName = null; string entryFilename = sourceEntry.File; TarEntry entry = (TarEntry)sourceEntry.Clone(); if (applyUserInfoOverrides) { entry.GroupId = groupId; entry.GroupName = groupName; entry.UserId = userId; entry.UserName = userName; } OnProgressMessageEvent(entry, null); if (asciiTranslate && !entry.IsDirectory) { if (!IsBinary(entryFilename)) { tempFileName = Path.GetTempFileName(); using (StreamReader inStream = File.OpenText(entryFilename)) { using (Stream outStream = File.Create(tempFileName)) { while (true) { string line = inStream.ReadLine(); if (line == null) { break; } byte[] data = Encoding.ASCII.GetBytes(line); outStream.Write(data, 0, data.Length); outStream.WriteByte((byte)'\n'); } outStream.Flush(); } } entry.Size = new FileInfo(tempFileName).Length; entryFilename = tempFileName; } } string newName = null; if (rootPath != null) { if (entry.Name.StartsWith(rootPath)) { newName = entry.Name.Substring(rootPath.Length + 1); } } if (pathPrefix != null) { newName = (newName == null) ? pathPrefix + "/" + entry.Name : pathPrefix + "/" + newName; } if (newName != null) { entry.Name = newName; } tarOut.PutNextEntry(entry); if (entry.IsDirectory) { if (recurse) { TarEntry[] list = entry.GetDirectoryEntries(); for (int i = 0; i < list.Length; ++i) { WriteEntryCore(list[i], recurse); } } } else { using (Stream inputStream = File.OpenRead(entryFilename)) { byte[] localBuffer = new byte[32 * 1024]; while (true) { int numRead = inputStream.Read(localBuffer, 0, localBuffer.Length); if (numRead <= 0) { break; } tarOut.Write(localBuffer, 0, numRead); } } if ((tempFileName != null) && (tempFileName.Length > 0)) { File.Delete(tempFileName); } tarOut.CloseEntry(); } }
private void InternalWriteEntry(TarEntry sourceEntry, bool recurse) { string path = null; string file = sourceEntry.File; TarEntry entry = (TarEntry)sourceEntry.Clone(); if (this.applyUserInfoOverrides) { entry.GroupId = this.groupId; entry.GroupName = this.groupName; entry.UserId = this.userId; entry.UserName = this.userName; } this.OnProgressMessageEvent(entry, null); if ((this.asciiTranslate && !entry.IsDirectory) && !this.IsBinary(file)) { path = Path.GetTempFileName(); StreamReader reader = File.OpenText(file); Stream stream = File.Create(path); while (true) { string s = reader.ReadLine(); if (s == null) { break; } byte[] bytes = Encoding.ASCII.GetBytes(s); stream.Write(bytes, 0, bytes.Length); stream.WriteByte(10); } reader.Close(); stream.Flush(); stream.Close(); entry.Size = new FileInfo(path).Length; file = path; } string str4 = null; if ((this.rootPath != null) && entry.Name.StartsWith(this.rootPath)) { str4 = entry.Name.Substring(this.rootPath.Length + 1); } if (this.pathPrefix != null) { str4 = (str4 == null) ? (this.pathPrefix + "/" + entry.Name) : (this.pathPrefix + "/" + str4); } if (str4 != null) { entry.Name = str4; } this.tarOut.PutNextEntry(entry); if (entry.IsDirectory) { if (recurse) { TarEntry[] directoryEntries = entry.GetDirectoryEntries(); for (int i = 0; i < directoryEntries.Length; i++) { this.InternalWriteEntry(directoryEntries[i], recurse); } } } else { Stream stream2 = File.OpenRead(file); int num2 = 0; byte[] buffer = new byte[0x8000]; while (true) { int count = stream2.Read(buffer, 0, buffer.Length); if (count <= 0) { break; } this.tarOut.Write(buffer, 0, count); num2 += count; } stream2.Close(); if ((path != null) && (path.Length > 0)) { File.Delete(path); } this.tarOut.CloseEntry(); } }
private void WriteEntryCore(TarEntry sourceEntry, bool recurse) { string path = null; bool flag; string file = sourceEntry.File; TarEntry entry = (TarEntry)sourceEntry.Clone(); if (this.applyUserInfoOverrides) { entry.GroupId = this.groupId; entry.GroupName = this.groupName; entry.UserId = this.userId; entry.UserName = this.userName; } this.OnProgressMessageEvent(entry, null); if ((this.asciiTranslate && !entry.IsDirectory) && !IsBinary(file)) { path = Path.GetTempFileName(); using (StreamReader reader = File.OpenText(file)) { using (Stream stream = File.Create(path)) { string str3; goto Label_00EB; Label_00A9: str3 = reader.ReadLine(); if (str3 == null) { goto Label_00F0; } byte[] bytes = Encoding.ASCII.GetBytes(str3); stream.Write(bytes, 0, bytes.Length); stream.WriteByte(10); Label_00EB: flag = true; goto Label_00A9; Label_00F0: stream.Flush(); } } entry.Size = new FileInfo(path).Length; file = path; } string str4 = null; if ((this.rootPath != null) && entry.Name.StartsWith(this.rootPath)) { str4 = entry.Name.Substring(this.rootPath.Length + 1); } if (this.pathPrefix != null) { str4 = (str4 == null) ? (this.pathPrefix + "/" + entry.Name) : (this.pathPrefix + "/" + str4); } if (str4 != null) { entry.Name = str4; } this.tarOut.PutNextEntry(entry); if (entry.IsDirectory) { if (recurse) { TarEntry[] directoryEntries = entry.GetDirectoryEntries(); for (int i = 0; i < directoryEntries.Length; i++) { this.WriteEntryCore(directoryEntries[i], recurse); } } return; } using (Stream stream2 = File.OpenRead(file)) { int num2; byte[] buffer = new byte[0x8000]; goto Label_0286; Label_0255: num2 = stream2.Read(buffer, 0, buffer.Length); if (num2 <= 0) { goto Label_02A2; } this.tarOut.Write(buffer, 0, num2); Label_0286: flag = true; goto Label_0255; } Label_02A2: if ((path != null) && (path.Length > 0)) { File.Delete(path); } this.tarOut.CloseEntry(); }
private void WriteEntryCore(TarEntry sourceEntry, bool recurse) { string path = null; string str3; string file = sourceEntry.File; TarEntry entry = (TarEntry)sourceEntry.Clone(); if (this.applyUserInfoOverrides) { entry.GroupId = this.groupId; entry.GroupName = this.groupName; entry.UserId = this.userId; entry.UserName = this.userName; } this.OnProgressMessageEvent(entry, null); if (this.asciiTranslate && (!entry.IsDirectory && !IsBinary(file))) { path = Path.GetTempFileName(); using (StreamReader reader = File.OpenText(file)) { Stream stream = File.Create(path); while (true) { try { while (true) { string s = reader.ReadLine(); if (s == null) { stream.Flush(); entry.Size = new FileInfo(path).Length; file = path; goto TR_0022; } else { byte[] bytes = Encoding.ASCII.GetBytes(s); stream.Write(bytes, 0, bytes.Length); stream.WriteByte(10); } break; } } finally { if (stream != null) { stream.Dispose(); } } } } } TR_0022: str3 = null; if ((this.rootPath != null) && entry.Name.StartsWith(this.rootPath, StringComparison.OrdinalIgnoreCase)) { str3 = entry.Name.Substring(this.rootPath.Length + 1); } if (this.pathPrefix != null) { str3 = (str3 == null) ? (this.pathPrefix + "/" + entry.Name) : (this.pathPrefix + "/" + str3); } if (str3 != null) { entry.Name = str3; } this.tarOut.PutNextEntry(entry); if (entry.IsDirectory) { if (recurse) { TarEntry[] directoryEntries = entry.GetDirectoryEntries(); for (int i = 0; i < directoryEntries.Length; i++) { this.WriteEntryCore(directoryEntries[i], recurse); } } } else { using (Stream stream2 = File.OpenRead(file)) { byte[] buffer = new byte[0x8000]; while (true) { int count = stream2.Read(buffer, 0, buffer.Length); if (count <= 0) { break; } this.tarOut.Write(buffer, 0, count); } } if ((path != null) && (path.Length > 0)) { File.Delete(path); } this.tarOut.CloseEntry(); } }
private void WriteEntryCore(TarEntry sourceEntry, bool recurse) { //IL_00de: Unknown result type (might be due to invalid IL or missing references) string text = null; string text2 = sourceEntry.File; TarEntry tarEntry = (TarEntry)sourceEntry.Clone(); if (applyUserInfoOverrides) { tarEntry.GroupId = groupId; tarEntry.GroupName = groupName; tarEntry.UserId = userId; tarEntry.UserName = userName; } OnProgressMessageEvent(tarEntry, null); if (asciiTranslate && !tarEntry.IsDirectory && !IsBinary(text2)) { text = Path.GetTempFileName(); StreamReader val = File.OpenText(text2); try { Stream val2 = (Stream)(object)File.Create(text); try { while (true) { string text3 = ((TextReader)val).ReadLine(); if (text3 == null) { break; } byte[] bytes = Encoding.get_ASCII().GetBytes(text3); val2.Write(bytes, 0, bytes.Length); val2.WriteByte((byte)10); } val2.Flush(); } finally { ((global::System.IDisposable)val2)?.Dispose(); } } finally { ((global::System.IDisposable)val)?.Dispose(); } tarEntry.Size = new FileInfo(text).get_Length(); text2 = text; } string text4 = null; if (rootPath != null && tarEntry.Name.StartsWith(rootPath)) { text4 = tarEntry.Name.Substring(rootPath.get_Length() + 1); } if (pathPrefix != null) { text4 = ((text4 == null) ? (pathPrefix + "/" + tarEntry.Name) : (pathPrefix + "/" + text4)); } if (text4 != null) { tarEntry.Name = text4; } tarOut.PutNextEntry(tarEntry); if (tarEntry.IsDirectory) { if (recurse) { TarEntry[] directoryEntries = tarEntry.GetDirectoryEntries(); for (int i = 0; i < directoryEntries.Length; i++) { WriteEntryCore(directoryEntries[i], recurse); } } return; } Stream val3 = (Stream)(object)File.OpenRead(text2); try { byte[] array = new byte[32768]; while (true) { int num = val3.Read(array, 0, array.Length); if (num > 0) { ((Stream)tarOut).Write(array, 0, num); continue; } break; } } finally { ((global::System.IDisposable)val3)?.Dispose(); } if (text != null && text.get_Length() > 0) { File.Delete(text); } tarOut.CloseEntry(); }
/// <summary> /// Write an entry to the archive. This method will call the putNextEntry /// and then write the contents of the entry, and finally call closeEntry() /// for entries that are files. For directories, it will call putNextEntry(), /// and then, if the recurse flag is true, process each entry that is a /// child of the directory. /// </summary> /// <param name="sourceEntry"> /// The TarEntry representing the entry to write to the archive. /// </param> /// <param name="recurse"> /// If true, process the children of directory entries. /// </param> void InternalWriteEntry(TarEntry sourceEntry, bool recurse) { bool asciiTrans = false; string tempFileName = null; string entryFilename = sourceEntry.File; TarEntry entry = (TarEntry)sourceEntry.Clone(); if ( applyUserInfoOverrides ) { entry.GroupId = groupId; entry.GroupName = groupName; entry.UserId = userId; entry.UserName = userName; } OnProgressMessageEvent(entry, null); if (this.asciiTranslate && !entry.IsDirectory) { asciiTrans = !IsBinary(entryFilename); if (asciiTrans) { tempFileName = Path.GetTempFileName(); StreamReader inStream = File.OpenText(entryFilename); Stream outStream = File.Create(tempFileName); while (true) { string line = inStream.ReadLine(); if (line == null) { break; } byte[] data = Encoding.ASCII.GetBytes(line); outStream.Write(data, 0, data.Length); outStream.WriteByte((byte)'\n'); } inStream.Close(); outStream.Flush(); outStream.Close(); entry.Size = new FileInfo(tempFileName).Length; entryFilename = tempFileName; } } string newName = null; if (this.rootPath != null) { if (entry.Name.StartsWith(this.rootPath)) { newName = entry.Name.Substring(this.rootPath.Length + 1 ); } } if (this.pathPrefix != null) { newName = (newName == null) ? this.pathPrefix + "/" + entry.Name : this.pathPrefix + "/" + newName; } if (newName != null) { entry.Name = newName; } this.tarOut.PutNextEntry(entry); if (entry.IsDirectory) { if (recurse) { TarEntry[] list = entry.GetDirectoryEntries(); for (int i = 0; i < list.Length; ++i) { InternalWriteEntry(list[i], recurse); } } } else { Stream inputStream = File.OpenRead(entryFilename); int numWritten = 0; byte[] eBuf = new byte[32 * 1024]; while (true) { int numRead = inputStream.Read(eBuf, 0, eBuf.Length); if (numRead <=0) { break; } this.tarOut.Write(eBuf, 0, numRead); numWritten += numRead; } inputStream.Close(); if (tempFileName != null && tempFileName.Length > 0) { File.Delete(tempFileName); } this.tarOut.CloseEntry(); } }