本文整理汇总了C#中ICSharpCode.SharpZipLib.Tar.TarEntry类的典型用法代码示例。如果您正苦于以下问题:C# TarEntry类的具体用法?C# TarEntry怎么用?C# TarEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TarEntry类属于ICSharpCode.SharpZipLib.Tar命名空间,在下文中一共展示了TarEntry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MyLister
public static void MyLister(TarArchive ta, TarEntry te, string msg)
{
if (te.Size > 0)
{
Console.WriteLine(te.Name + " " + te.Size);
totalsize = totalsize + 1;
}
}
开发者ID:habbim,项目名称:TraslatorInstaller,代码行数:8,代码来源:Program.cs
示例2: WriteObjectToTar
private void WriteObjectToTar (TarOutputStream tar_out,
FileSystemObject fso,
EventTracker tracker)
{
MemoryStream memory = null;
TarHeader header;
header = new TarHeader ();
StringBuilder name_builder;
name_builder = new StringBuilder (fso.FullName);
name_builder.Remove (0, this.FullName.Length+1);
header.Name = name_builder.ToString ();
header.ModTime = fso.Timestamp;
if (fso is DirectoryObject) {
header.Mode = 511; // 0777
header.TypeFlag = TarHeader.LF_DIR;
header.Size = 0;
} else {
header.Mode = 438; // 0666
header.TypeFlag = TarHeader.LF_NORMAL;
memory = new MemoryStream ();
((FileObject) fso).AddToStream (memory, tracker);
header.Size = memory.Length;
}
TarEntry entry;
entry = new TarEntry (header);
tar_out.PutNextEntry (entry);
if (memory != null) {
tar_out.Write (memory.ToArray (), 0, (int) memory.Length);
memory.Close ();
}
tar_out.CloseEntry ();
// If this is a directory, write out the children
if (fso is DirectoryObject)
foreach (FileSystemObject child in fso.Children)
WriteObjectToTar (tar_out, child, tracker);
}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:42,代码来源:TarFileObject.cs
示例3: OnProgressMessageEvent
/// <summary>
/// Raises the ProgressMessage event
/// </summary>
/// <param name="entry">The <see cref="TarEntry">TarEntry</see> for this event</param>
/// <param name="message">message for this event. Null is no message</param>
protected virtual void OnProgressMessageEvent(TarEntry entry, string message)
{
ProgressMessageHandler handler = ProgressMessageEvent;
if (handler != null) {
handler(this, entry, message);
}
}
开发者ID:jamesbascle,项目名称:SharpZipLib,代码行数:12,代码来源:TarArchive.cs
示例4: ExtractEntry
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);
}
}
}
开发者ID:fundies,项目名称:Aegisub,代码行数:17,代码来源:TarballProject.cs
示例5: PutNextEntry
/// <summary>
/// Put an entry on the output stream. This writes the entry's
/// header and positions the output stream for writing
/// the contents of the entry. Once this method is called, the
/// stream is ready for calls to write() to write the entry's
/// contents. Once the contents are written, closeEntry()
/// <B>MUST</B> be called to ensure that all buffered data
/// is completely written to the output stream.
/// </summary>
/// <param name="entry">
/// The TarEntry to be written to the archive.
/// </param>
public void PutNextEntry(TarEntry entry)
{
if ( entry == null ) {
throw new ArgumentNullException("entry");
}
if (entry.TarHeader.Name.Length >= TarHeader.NAMELEN) {
TarHeader longHeader = new TarHeader();
longHeader.TypeFlag = TarHeader.LF_GNU_LONGNAME;
longHeader.Name = longHeader.Name + "././@LongLink";
longHeader.UserId = 0;
longHeader.GroupId = 0;
longHeader.GroupName = "";
longHeader.UserName = "";
longHeader.LinkName = "";
longHeader.Size = entry.TarHeader.Name.Length;
longHeader.WriteHeader(blockBuffer);
buffer.WriteBlock(blockBuffer); // Add special long filename header block
int nameCharIndex = 0;
while (nameCharIndex < entry.TarHeader.Name.Length) {
Array.Clear(blockBuffer, 0, blockBuffer.Length);
TarHeader.GetAsciiBytes(entry.TarHeader.Name, nameCharIndex, this.blockBuffer, 0, TarBuffer.BlockSize);
nameCharIndex += TarBuffer.BlockSize;
buffer.WriteBlock(blockBuffer);
}
}
entry.WriteEntryHeader(blockBuffer);
buffer.WriteBlock(blockBuffer);
currBytes = 0;
currSize = entry.IsDirectory ? 0 : entry.Size;
}
开发者ID:AlmatoolboxCE,项目名称:AlmaStyleFix,代码行数:49,代码来源:TarOutputStream.cs
示例6: PutNextEntry
/// <summary>
/// Put an entry on the output stream. This writes the entry's
/// header and positions the output stream for writing
/// the contents of the entry. Once this method is called, the
/// stream is ready for calls to write() to write the entry's
/// contents. Once the contents are written, closeEntry()
/// <B>MUST</B> be called to ensure that all buffered data
/// is completely written to the output stream.
/// </summary>
/// <param name="entry">
/// The TarEntry to be written to the archive.
/// </param>
public void PutNextEntry(TarEntry entry)
{
if (entry.TarHeader.name.Length > TarHeader.NAMELEN)
{
TarHeader longHeader = new TarHeader();
longHeader.typeFlag = TarHeader.LF_GNU_LONGNAME;
longHeader.name.Append("././@LongLink");
longHeader.userId = 0;
longHeader.groupId = 0;
longHeader.groupName.Length = 0;
longHeader.userName.Length = 0;
longHeader.linkName.Length = 0;
longHeader.size = entry.TarHeader.name.Length;
Console.WriteLine("TarOutputStream: PutNext entry Long name found size = " + longHeader.size); // DEBUG
longHeader.WriteHeader(this.blockBuf);
this.buffer.WriteBlock(this.blockBuf); // Add special long filename header block
int nameCharIndex = 0;
while (nameCharIndex < entry.TarHeader.name.Length)
{
TarHeader.GetNameBytes(entry.TarHeader.name, nameCharIndex, this.blockBuf, 0, TarBuffer.BlockSize);
nameCharIndex += TarBuffer.BlockSize;
this.buffer.WriteBlock(this.blockBuf);
}
}
entry.WriteEntryHeader(this.blockBuf);
this.buffer.WriteBlock(this.blockBuf);
this.currBytes = 0;
this.currSize = entry.IsDirectory ? 0 : (int)entry.Size;
}
开发者ID:jack-pappas,项目名称:mono,代码行数:49,代码来源:TarOutputStream.cs
示例7: GetNextEntry
/// <summary>
/// Get the next entry in this tar archive. This will skip
/// over any remaining data in the current entry, if there
/// is one, and place the input stream at the header of the
/// next entry, and read the header and instantiate a new
/// TarEntry from the header bytes and return that entry.
/// If there are no more entries in the archive, null will
/// be returned to indicate that the end of the archive has
/// been reached.
/// </summary>
/// <returns>
/// The next TarEntry in the archive, or null.
/// </returns>
public TarEntry GetNextEntry()
{
if (hasHitEOF) {
return null;
}
if (currentEntry != null) {
SkipToNextEntry();
}
byte[] headerBuf = tarBuffer.ReadBlock();
if (headerBuf == null) {
hasHitEOF = true;
} else
hasHitEOF |= TarBuffer.IsEndOfArchiveBlock(headerBuf);
if (hasHitEOF) {
currentEntry = null;
} else {
try {
var header = new TarHeader();
header.ParseBuffer(headerBuf);
if (!header.IsChecksumValid) {
throw new TarException("Header checksum is invalid");
}
this.entryOffset = 0;
this.entrySize = header.Size;
StringBuilder longName = null;
if (header.TypeFlag == TarHeader.LF_GNU_LONGNAME) {
byte[] nameBuffer = new byte[TarBuffer.BlockSize];
long numToRead = this.entrySize;
longName = new StringBuilder();
while (numToRead > 0) {
int numRead = this.Read(nameBuffer, 0, (numToRead > nameBuffer.Length ? nameBuffer.Length : (int)numToRead));
if (numRead == -1) {
throw new InvalidHeaderException("Failed to read long name entry");
}
longName.Append(TarHeader.ParseName(nameBuffer, 0, numRead).ToString());
numToRead -= numRead;
}
SkipToNextEntry();
headerBuf = this.tarBuffer.ReadBlock();
} else if (header.TypeFlag == TarHeader.LF_GHDR) { // POSIX global extended header
// Ignore things we dont understand completely for now
SkipToNextEntry();
headerBuf = this.tarBuffer.ReadBlock();
} else if (header.TypeFlag == TarHeader.LF_XHDR) { // POSIX extended header
// Ignore things we dont understand completely for now
SkipToNextEntry();
headerBuf = this.tarBuffer.ReadBlock();
} else if (header.TypeFlag == TarHeader.LF_GNU_VOLHDR) {
// TODO: could show volume name when verbose
SkipToNextEntry();
headerBuf = this.tarBuffer.ReadBlock();
} else if (header.TypeFlag != TarHeader.LF_NORMAL &&
header.TypeFlag != TarHeader.LF_OLDNORM &&
header.TypeFlag != TarHeader.LF_LINK &&
header.TypeFlag != TarHeader.LF_SYMLINK &&
header.TypeFlag != TarHeader.LF_DIR) {
// Ignore things we dont understand completely for now
SkipToNextEntry();
headerBuf = tarBuffer.ReadBlock();
}
if (entryFactory == null) {
currentEntry = new TarEntry(headerBuf);
if (longName != null) {
currentEntry.Name = longName.ToString();
}
} else {
currentEntry = entryFactory.CreateEntry(headerBuf);
}
// Magic was checked here for 'ustar' but there are multiple valid possibilities
// so this is not done anymore.
entryOffset = 0;
//.........这里部分代码省略.........
开发者ID:Zo0pZ,项目名称:SharpZipLib,代码行数:101,代码来源:TarInputStream.cs
示例8: ShowTarProgressMessage
/// <summary>
/// Display progress information on console
/// </summary>
public void ShowTarProgressMessage(TarArchive archive, TarEntry entry, string message)
{
if (entry.TarHeader.TypeFlag != TarHeader.LF_NORMAL && entry.TarHeader.TypeFlag != TarHeader.LF_OLDNORM) {
Console.WriteLine("Entry type " + (char)entry.TarHeader.TypeFlag + " found!");
}
if (message != null)
Console.Write(entry.Name + " " + message);
else {
if (this.verbose) {
string modeString = DecodeType(entry.TarHeader.TypeFlag, entry.Name.EndsWith("/")) + DecodeMode(entry.TarHeader.Mode);
string userString = (entry.UserName == null || entry.UserName.Length == 0) ? entry.UserId.ToString() : entry.UserName;
string groupString = (entry.GroupName == null || entry.GroupName.Length == 0) ? entry.GroupId.ToString() : entry.GroupName;
Console.WriteLine(string.Format("{0} {1}/{2} {3,8} {4:yyyy-MM-dd HH:mm:ss} {5}", modeString, userString, groupString, entry.Size, entry.ModTime.ToLocalTime(), entry.Name));
} else {
Console.WriteLine(entry.Name);
}
}
}
开发者ID:jeske,项目名称:StepsDB-alpha,代码行数:23,代码来源:Main.cs
示例9: PostCreate
protected abstract void PostCreate(TarEntry entry);
开发者ID:AkariAkaori,项目名称:KaoriStudio,代码行数:1,代码来源:TarFileSystem.cs
示例10: FromEntry
public static TarFileSystemInfo FromEntry(TarFileSystem tfs, TarEntry entry)
{
TarFileSystemInfo fsi;
if (entry.IsDirectory)
fsi = new TarDirectoryInfo();
else
fsi = new TarFileInfo();
fsi.tfs = tfs;
fsi.CreationTime = entry.ModTime;
fsi.Exists = true;
fsi.FullName = entry.Name;
fsi.LastAccessTime = entry.ModTime;
fsi.LastWriteTime = entry.ModTime;
fsi.Name = entry.Name.PostLastCharacter('/');
fsi.Extension = entry.IsDirectory ? string.Empty : fsi.Name.PostFirstCharacter('.', string.Empty);
fsi.PostCreate(entry);
return fsi;
}
开发者ID:AkariAkaori,项目名称:KaoriStudio,代码行数:21,代码来源:TarFileSystem.cs
示例11: ExtractEntry
/// <summary>
/// Extract an entry from the archive. This method assumes that the
/// tarIn stream has been properly set with a call to getNextEntry().
/// </summary>
/// <param name="destDir">
/// The destination directory into which to extract.
/// </param>
/// <param name="entry">
/// The TarEntry returned by tarIn.getNextEntry().
/// </param>
void ExtractEntry(string destDir, TarEntry entry)
{
if (this.verbose) {
OnProgressMessageEvent(entry, null);
}
string name = entry.Name;
if (Path.IsPathRooted(name) == true) {
// NOTE:
// for UNC names... \\machine\share\zoom\beet.txt gives \zoom\beet.txt
name = name.Substring(Path.GetPathRoot(name).Length);
}
name = name.Replace('/', Path.DirectorySeparatorChar);
string destFile = Path.Combine(destDir, name);
if (entry.IsDirectory) {
EnsureDirectoryExists(destFile);
} else {
string parentDirectory = Path.GetDirectoryName(destFile);
EnsureDirectoryExists(parentDirectory);
bool process = true;
FileInfo fileInfo = new FileInfo(destFile);
if (fileInfo.Exists) {
if (this.keepOldFiles) {
OnProgressMessageEvent(entry, "Destination file already exists");
process = false;
} else if ((fileInfo.Attributes & FileAttributes.ReadOnly) != 0) {
OnProgressMessageEvent(entry, "Destination file already exists, and is read-only");
process = false;
}
}
if (process) {
bool asciiTrans = false;
// TODO file may exist and be read-only at this point!
Stream outputStream = File.Create(destFile);
if (this.asciiTranslate) {
asciiTrans = !IsBinary(destFile);
// TODO do we need this stuff below?
// original java sourcecode :
// MimeType mime = null;
// string contentType = null;
// try {
// contentType = FileTypeMap.getDefaultFileTypeMap().getContentType( destFile );
//
// mime = new MimeType(contentType);
//
// if (mime.getPrimaryType().equalsIgnoreCase( "text" )) {
// asciiTrans = true;
// } else if ( this.transTyper != null ) {
// if ( this.transTyper.isAsciiFile( entry.getName() ) ) {
// asciiTrans = true;
// }
// }
// } catch (MimeTypeParseException ex) {
// }
//
// if (this.debug) {
// Console.Error.WriteLine(("EXTRACT TRANS? '" + asciiTrans + "' ContentType='" + contentType + "' PrimaryType='" + mime.getPrimaryType() + "'" );
// }
}
StreamWriter outw = null;
if (asciiTrans) {
outw = new StreamWriter(outputStream);
}
byte[] rdbuf = new byte[32 * 1024];
while (true) {
int numRead = this.tarIn.Read(rdbuf, 0, rdbuf.Length);
if (numRead <= 0) {
break;
}
if (asciiTrans) {
for (int off = 0, b = 0; b < numRead; ++b) {
if (rdbuf[b] == 10) {
string s = Encoding.ASCII.GetString(rdbuf, off, (b - off));
outw.WriteLine(s);
off = b + 1;
}
}
} else {
outputStream.Write(rdbuf, 0, numRead);
//.........这里部分代码省略.........
开发者ID:foresightbrand,项目名称:brandqq,代码行数:101,代码来源:TarArchive.cs
示例12: IsDescendent
/// <summary>
/// Determine if the given entry is a descendant of this entry.
/// Descendancy is determined by the name of the descendant
/// starting with this entry's name.
/// </summary>
/// <param name = "desc">
/// Entry to be checked as a descendent of this.
/// </param>
/// <returns>
/// True if entry is a descendant of this.
/// </returns>
public bool IsDescendent(TarEntry desc)
{
return desc.header.name.ToString().StartsWith(this.header.name.ToString());
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:15,代码来源:TarEntry.cs
示例13: IsDescendent
/// <summary>
/// Determine if the given entry is a descendant of this entry.
/// Descendancy is determined by the name of the descendant
/// starting with this entry's name.
/// </summary>
/// <param name = "toTest">
/// Entry to be checked as a descendent of this.
/// </param>
/// <returns>
/// True if entry is a descendant of this.
/// </returns>
public bool IsDescendent(TarEntry toTest)
{
if ( toTest == null ) {
throw new ArgumentNullException("toTest");
}
return toTest.Name.StartsWith(Name);
}
开发者ID:lPinchol,项目名称:Reign-Unity-Plugin,代码行数:19,代码来源:TarEntry.cs
示例14: CreateTarEntry
/// <summary>
/// Construct an entry with only a <paramref name="name">name</paramref>.
/// This allows the programmer to construct the entry's header "by hand".
/// </summary>
/// <param name="name">The name to use for the entry</param>
/// <returns>Returns the newly created <see cref="TarEntry"/></returns>
public static TarEntry CreateTarEntry(string name)
{
TarEntry entry = new TarEntry();
TarEntry.NameTarHeader(entry.header, name);
return entry;
}
开发者ID:lPinchol,项目名称:Reign-Unity-Plugin,代码行数:12,代码来源:TarEntry.cs
示例15: CreateEntryFromFile
/// <summary>
/// Construct an entry for a file. File is set to file, and the
/// header is constructed from information from the file.
/// </summary>
/// <param name = "fileName">The file name that the entry represents.</param>
/// <returns>Returns the newly created <see cref="TarEntry"/></returns>
public static TarEntry CreateEntryFromFile(string fileName)
{
var entry = new TarEntry();
entry.GetFileTarHeader(entry.header, fileName);
return entry;
}
开发者ID:,项目名称:,代码行数:12,代码来源:
示例16: WriteEntry
/// <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>
public void WriteEntry(TarEntry sourceEntry, bool recurse)
{
if ( sourceEntry == null ) {
throw new ArgumentNullException("sourceEntry");
}
if ( isDisposed ) {
throw new ObjectDisposedException("TarArchive");
}
try
{
if ( recurse ) {
TarHeader.SetValueDefaults(sourceEntry.UserId, sourceEntry.UserName,
sourceEntry.GroupId, sourceEntry.GroupName);
}
WriteEntryCore(sourceEntry, recurse);
}
finally
{
if ( recurse ) {
TarHeader.RestoreSetValues();
}
}
}
开发者ID:jamesbascle,项目名称:SharpZipLib,代码行数:38,代码来源:TarArchive.cs
示例17: Clone
/// <summary>
/// Clone this tar entry.
/// </summary>
/// <returns>Returns a clone of this entry.</returns>
public object Clone()
{
TarEntry entry = new TarEntry();
entry.file = file;
entry.header = (TarHeader)header.Clone();
entry.Name = Name;
return entry;
}
开发者ID:lPinchol,项目名称:Reign-Unity-Plugin,代码行数:12,代码来源:TarEntry.cs
示例18: WriteEntryCore
/// <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);
}
//.........这里部分代码省略.........
开发者ID:jamesbascle,项目名称:SharpZipLib,代码行数:101,代码来源:TarArchive.cs
示例19: OnProgressMessageEvent
/// <summary>
/// Raises the ProgressMessage event
/// </summary>
/// <param name="entry">TarEntry for this event</param>
/// <param name="message">message for this event. Null is no message</param>
protected virtual void OnProgressMessageEvent(TarEntry entry, string message)
{
if (ProgressMessageEvent != null) {
ProgressMessageEvent(this, entry, message);
}
}
开发者ID:nrrrdcore,项目名称:newthing,代码行数:11,代码来源:TarArchive.cs
示例20: ExtractEntry
/// <summary>
/// Extract an entry from the archive. This method assumes that the
/// tarIn stream has been properly set with a call to GetNextEntry().
/// </summary>
/// <param name="destDir">
/// The destination directory into which to extract.
/// </param>
/// <param name="entry">
/// The TarEntry returned by tarIn.GetNextEntry().
/// </param>
void ExtractEntry(string destDir, TarEntry entry)
{
OnProgressMessageEvent(entry, null);
string name = entry.Name;
if (Path.IsPathRooted(name)) {
// NOTE:
// for UNC names... \\machine\share\zoom\beet.txt gives \zoom\beet.txt
name = name.Substring(Path.GetPathRoot(name).Length);
}
name = name.Replace('/', Path.DirectorySeparatorChar);
string destFile = Path.Combine(destDir, name);
if (entry.IsDirectory) {
EnsureDirectoryExists(destFile);
} else {
string parentDirectory = Path.GetDirectoryName(destFile);
EnsureDirectoryExists(parentDirectory);
bool process = true;
FileInfo fileInfo = new FileInfo(destFile);
if (fileInfo.Exists) {
if (keepOldFiles) {
OnProgressMessageEvent(entry, "Destination file already exists");
process = false;
} else if ((fileInfo.Attributes & FileAttributes.ReadOnly) != 0) {
OnProgressMessageEvent(entry, "Destination file already exists, and is read-only");
process = false;
}
}
if (process) {
bool asciiTrans = false;
Stream outputStream = File.Create(destFile);
if (this.asciiTranslate) {
asciiTrans = !IsBinary(destFile);
}
StreamWriter outw = null;
if (asciiTrans) {
outw = new StreamWriter(outputStream);
}
byte[] rdbuf = new byte[32 * 1024];
while (true) {
int numRead = tarIn.Read(rdbuf, 0, rdbuf.Length);
if (numRead <= 0) {
break;
}
if (asciiTrans) {
for (int off = 0, b = 0; b < numRead; ++b) {
if (rdbuf[b] == 10) {
string s = Encoding.ASCII.GetString(rdbuf, off, (b - off));
outw.WriteLine(s);
off = b + 1;
}
}
} else {
outputStream.Write(rdbuf, 0, numRead);
}
}
if (asciiTrans) {
outw.Close();
} else {
outputStream.Close();
}
}
}
}
开发者ID:jamesbascle,项目名称:SharpZipLib,代码行数:87,代码来源:TarArchive.cs
注:本文中的ICSharpCode.SharpZipLib.Tar.TarEntry类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论