本文整理汇总了C#中Stream.ReadASCIIZ方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.ReadASCIIZ方法的具体用法?C# Stream.ReadASCIIZ怎么用?C# Stream.ReadASCIIZ使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream.ReadASCIIZ方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deserialize
public void Deserialize(Stream stream)
{
List<PackageEntry> entries = new List<PackageEntry>();
// Types
while (true)
{
string typeName = stream.ReadASCIIZ();
if (typeName == "")
{
break;
}
// Directories
while (true)
{
string directoryName = stream.ReadASCIIZ();
if (directoryName == "")
{
break;
}
// Files
while (true)
{
string fileName = stream.ReadASCIIZ();
if (fileName == "")
{
break;
}
PackageEntry entry = new PackageEntry();
entry.FileName = fileName;
entry.DirectoryName = directoryName.Replace("/", "\\");
entry.TypeName = typeName;
entry.HashOrTimestamp = stream.ReadU32();
entry.SmallData = new byte[stream.ReadU16()];
entry.ArchiveIndex = stream.ReadU16();
entry.Offset = stream.ReadU32();
entry.Size = stream.ReadU32();
entry.Unknown = stream.ReadU16();
if (entry.Unknown != 0xFFFF)
{
throw new PackageFileException();
}
if (entry.SmallData.Length > 0)
{
stream.Read(entry.SmallData, 0, entry.SmallData.Length);
}
entries.Add(entry);
}
}
}
this.Entries = entries;
}
示例2: D2kSoundResources
public D2kSoundResources(string filename, int priority)
{
this.filename = filename;
this.priority = priority;
s = GlobalFileSystem.Open(filename);
try
{
filenames = new List<string>();
var headerLength = s.ReadUInt32();
while (s.Position < headerLength + 4)
{
var name = s.ReadASCIIZ();
var offset = s.ReadUInt32();
var length = s.ReadUInt32();
var hash = PackageEntry.HashFilename(name, PackageHashType.Classic);
if (!index.ContainsKey(hash))
index.Add(hash, new PackageEntry(hash, offset, length));
filenames.Add(name);
}
}
catch
{
Dispose();
throw;
}
}
示例3: PakFile
public PakFile(string filename, int priority)
{
this.filename = filename;
this.priority = priority;
index = new Dictionary<string, Entry>();
stream = GlobalFileSystem.Open(filename);
try
{
index = new Dictionary<string, Entry>();
var offset = stream.ReadUInt32();
while (offset != 0)
{
var file = stream.ReadASCIIZ();
var next = stream.ReadUInt32();
var length = (next == 0 ? (uint)stream.Length : next) - offset;
// Ignore duplicate files
if (index.ContainsKey(file))
continue;
index.Add(file, new Entry { Offset = offset, Length = length, Filename = file });
offset = next;
}
}
catch
{
Dispose();
throw;
}
}
示例4: FileGroup
public FileGroup(Stream reader, long offset)
{
var nameOffset = reader.ReadUInt32();
/* unknown */ reader.ReadBytes(18);
FirstFile = reader.ReadUInt32();
LastFile = reader.ReadUInt32();
reader.Seek(offset + (long)nameOffset, SeekOrigin.Begin);
Name = reader.ReadASCIIZ();
}
示例5: Entry
public Entry(Stream s)
{
this.s = s;
offset = s.ReadUInt32();
size = s.ReadUInt32();
if (BitConverter.IsLittleEndian)
{
offset = int2.Swap(offset);
size = int2.Swap(size);
}
Path = s.ReadASCIIZ();
}
示例6: FileDescriptor
public FileDescriptor(Stream reader, long tableOffset)
{
Flags = reader.ReadUInt16();
ExpandedSize = reader.ReadUInt32();
/* unknown */ reader.ReadUInt32();
CompressedSize = reader.ReadUInt32();
/* unknown */ reader.ReadUInt32();
DataOffset = reader.ReadUInt32();
/* unknown */ reader.ReadUInt32();
MD5 = reader.ReadBytes(16);
/* unknown */ reader.ReadBytes(16);
NameOffset = reader.ReadUInt32();
DirectoryIndex = reader.ReadUInt16();
/* unknown */ reader.ReadBytes(12);
LinkToPrevious = reader.ReadUInt32();
LinkToNext = reader.ReadUInt32();
LinkFlags = reader.ReadBytes(1)[0];
Volume = reader.ReadUInt16();
var posSave = reader.Position;
reader.Seek(tableOffset + NameOffset, SeekOrigin.Begin);
Filename = reader.ReadASCIIZ();
reader.Seek(posSave, SeekOrigin.Begin);
}
示例7: FileGroup
public FileGroup(Stream stream, long offset)
{
var nameOffset = stream.ReadUInt32();
stream.Position += 18;
FirstFile = stream.ReadUInt32();
LastFile = stream.ReadUInt32();
var pos = stream.Position;
stream.Position = offset + nameOffset;
Name = stream.ReadASCIIZ();
stream.Position = pos;
}
示例8: FileDescriptor
public FileDescriptor(Stream stream, uint index, long tableOffset)
{
Index = index;
Flags = (CABFlags)stream.ReadUInt16();
ExpandedSize = stream.ReadUInt32();
stream.Position += 4;
CompressedSize = stream.ReadUInt32();
stream.Position += 4;
DataOffset = stream.ReadUInt32();
stream.Position += 4;
MD5 = stream.ReadBytes(16);
stream.Position += 16;
NameOffset = stream.ReadUInt32();
DirectoryIndex = stream.ReadUInt16();
stream.Position += 12;
LinkToPrevious = stream.ReadUInt32();
LinkToNext = stream.ReadUInt32();
LinkFlags = (LinkFlags)stream.ReadUInt8();
Volume = stream.ReadUInt16();
var pos = stream.Position;
stream.Position = tableOffset + NameOffset;
Filename = stream.ReadASCIIZ();
stream.Position = pos;
}
示例9: DirectoryDescriptor
public DirectoryDescriptor(Stream stream, long nameTableOffset)
{
var nameOffset = stream.ReadUInt32();
var pos = stream.Position;
stream.Position = nameTableOffset + nameOffset;
Name = stream.ReadASCIIZ();
stream.Position = pos;
}
示例10: CabFile
public CabFile(Stream stream)
{
DecompressedLength = stream.ReadUInt32();
DecompressedOffset = stream.ReadUInt32();
FolderIndex = stream.ReadUInt16();
stream.Position += 6;
FileName = stream.ReadASCIIZ();
}