public WriteBlock ( byte block ) : void | ||
block | byte | /// The data to write to the archive. /// |
리턴 | void |
public void PutNextEntry(TarEntry entry) { if (entry == null) { throw new ArgumentNullException("entry"); } if (entry.TarHeader.Name.Length >= 100) { TarHeader tarHeader = new TarHeader(); tarHeader.TypeFlag = 76; tarHeader.Name += "././@LongLink"; tarHeader.UserId = 0; tarHeader.GroupId = 0; tarHeader.GroupName = ""; tarHeader.UserName = ""; tarHeader.LinkName = ""; tarHeader.Size = entry.TarHeader.Name.Length; tarHeader.WriteHeader(blockBuffer); buffer.WriteBlock(blockBuffer); int num = 0; while (num < entry.TarHeader.Name.Length) { Array.Clear(blockBuffer, 0, blockBuffer.Length); TarHeader.GetAsciiBytes(entry.TarHeader.Name, num, blockBuffer, 0, 512); num += 512; buffer.WriteBlock(blockBuffer); } } entry.WriteEntryHeader(blockBuffer); buffer.WriteBlock(blockBuffer); currBytes = 0L; currSize = (entry.IsDirectory ? 0 : entry.Size); }
public void PutNextEntry(TarEntry entry) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (entry == null) { throw new ArgumentNullException("entry"); } if (entry.TarHeader.Name.get_Length() >= 100) { TarHeader tarHeader = new TarHeader(); tarHeader.TypeFlag = 76; tarHeader.Name += "././@LongLink"; tarHeader.UserId = 0; tarHeader.GroupId = 0; tarHeader.GroupName = ""; tarHeader.UserName = ""; tarHeader.LinkName = ""; tarHeader.Size = entry.TarHeader.Name.get_Length(); tarHeader.WriteHeader(blockBuffer); buffer.WriteBlock(blockBuffer); int num = 0; while (num < entry.TarHeader.Name.get_Length()) { global::System.Array.Clear((global::System.Array)blockBuffer, 0, blockBuffer.Length); TarHeader.GetAsciiBytes(entry.TarHeader.Name, num, blockBuffer, 0, 512); num += 512; buffer.WriteBlock(blockBuffer); } } entry.WriteEntryHeader(blockBuffer); buffer.WriteBlock(blockBuffer); currBytes = 0L; currSize = (entry.IsDirectory ? 0 : entry.Size); }
/// <summary> /// Close an entry. This method MUST be called for all file /// entries that contain data. The reason is that we must /// buffer data written to the stream in order to satisfy /// the buffer's block based writes. Thus, there may be /// data fragments still being assembled that must be written /// to the output stream before this entry is closed and the /// next entry written. /// </summary> public void CloseEntry() { if (assemblyBufferLength > 0) { Array.Clear(assemblyBuffer, assemblyBufferLength, assemblyBuffer.Length - assemblyBufferLength); buffer.WriteBlock(assemblyBuffer); currBytes += assemblyBufferLength; assemblyBufferLength = 0; } if (currBytes < currSize) { string errorText = string.Format( "Entry closed at '{0}' before the '{1}' bytes specified in the header were written", currBytes, currSize); throw new TarException(errorText); } }
/// <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) { var 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(blockBuf); buffer.WriteBlock(blockBuf); // Add special long filename header block var nameCharIndex = 0; while (nameCharIndex < entry.TarHeader.Name.Length) { Array.Clear(blockBuf, 0, blockBuf.Length); TarHeader.GetAsciiBytes(entry.TarHeader.Name, nameCharIndex, blockBuf, 0, TarBuffer.BlockSize); nameCharIndex += TarBuffer.BlockSize; buffer.WriteBlock(blockBuf); } } entry.WriteEntryHeader(blockBuf); buffer.WriteBlock(blockBuf); currBytes = 0; currSize = entry.IsDirectory ? 0 : entry.Size; }