本文整理汇总了C#中ByteBuffer.WriteUInt32方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.WriteUInt32方法的具体用法?C# ByteBuffer.WriteUInt32怎么用?C# ByteBuffer.WriteUInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.WriteUInt32方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteArchiveDirectoryEntryToStream
internal void WriteArchiveDirectoryEntryToStream(Stream writer)
{
//File header (in central directory):
//
//central file header signature 4 bytes (0x02014b50)
//version made by 2 bytes
//version needed to extract 2 bytes
//general purpose bit flag 2 bytes
//compression method 2 bytes
//last mod file time 2 bytes
//last mod file date 2 bytes
//crc-32 4 bytes
//compressed size 4 bytes
//uncompressed size 4 bytes
//file name length 2 bytes
//extra field length 2 bytes
//file comment length 2 bytes
//disk number start 2 bytes
//internal file attributes 2 bytes
//external file attributes 4 bytes
//relative offset of local header 4 bytes
//
//file name (variable size)
//extra field (variable size)
//file comment (variable size)
byte[] fileNameBytes = Encoding.UTF8.GetBytes(name);
ByteBuffer header = new ByteBuffer(46);
header.WriteUInt32(SignatureArchiveDirectory);
header.WriteUInt16(VersionMadeBy);
header.WriteUInt16(VersionNeededToExtract);
header.WriteUInt16(GeneralPurposeBitFlag);
header.WriteUInt16((ushort)compressionMethod);
header.WriteUInt32(DateTimeToDosTime(lastWriteTime));
header.WriteUInt32(CheckSum);
header.WriteUInt32((uint)compressedLength);
header.WriteUInt32((uint)Length);
header.WriteUInt16((ushort)fileNameBytes.Length);
header.WriteUInt16(ExtraFieldLength);
header.WriteUInt16(FileCommentLength);
header.WriteUInt16(DiskNumberStart);
header.WriteUInt16(InternalFileAttributes);
header.WriteUInt32(ExternalFileAttributes);
header.WriteUInt32(headerOffset);
header.WriteContentsTo(writer);
writer.Write(fileNameBytes, 0, fileNameBytes.Length);
}
示例2: WriteZipFileHeader
private void WriteZipFileHeader(Stream writer)
{
byte[] fileNameBytes = Encoding.UTF8.GetBytes(name.Replace(Path.DirectorySeparatorChar, '/'));
if ((uint)length != length)
throw new ApplicationException("File length too long.");
//Local file header:
//
//local file header signature 4 bytes (0x04034b50)
//version needed to extract 2 bytes
//general purpose bit flag 2 bytes
//compression method 2 bytes
//last mod file time 2 bytes
//last mod file date 2 bytes
//crc-32 4 bytes
//compressed size 4 bytes
//uncompressed size 4 bytes
//file name length 2 bytes
//extra field length 2 bytes
//
//file name (variable size)
//extra field (variable size)
// save the start of the header file for later use in the directory entry
headerOffset = (uint)writer.Position;
ByteBuffer header = new ByteBuffer(30);
header.WriteUInt32(SignatureFileEntry);
header.WriteUInt16(VersionNeededToExtract);
header.WriteUInt16(GeneralPurposeBitFlag);
header.WriteUInt16((ushort)compressionMethod);
header.WriteUInt32(DateTimeToDosTime(lastWriteTime));
header.WriteUInt32(CheckSum);
header.WriteUInt32((uint)compressedLength);
header.WriteUInt32((uint)Length);
header.WriteUInt16((ushort)fileNameBytes.Length);
header.WriteUInt16(ExtraFieldLength); // extra field length (unused)
header.WriteContentsTo(writer);
writer.Write(fileNameBytes, 0, fileNameBytes.Length); // Write the archiveFile name.
}
示例3: WriteArchiveDirectoryToStream
private void WriteArchiveDirectoryToStream(Stream writer)
{
// Write the directory entries.
long startOfDirectory = writer.Position;
foreach (ZipArchiveFile entry in entries.Values)
entry.WriteArchiveDirectoryEntryToStream(writer);
long endOfDirectory = writer.Position;
// Write the trailer
ByteBuffer trailer = new ByteBuffer(22);
trailer.WriteUInt32(ZipArchiveFile.SignatureArchiveDirectoryEnd);
trailer.WriteUInt16(ZipArchiveFile.DiskNumberStart);
trailer.WriteUInt16(ZipArchiveFile.DiskNumberStart);
trailer.WriteUInt16((ushort)entries.Count);
trailer.WriteUInt16((ushort)entries.Count);
trailer.WriteUInt32((uint)(endOfDirectory - startOfDirectory)); // directory size
trailer.WriteUInt32((uint)startOfDirectory); // directory start
trailer.WriteUInt16((ushort)ZipArchiveFile.FileCommentLength);
trailer.WriteContentsTo(writer);
}