public VirtualFile OpenFile(string filename, FileFormat f = FileFormat.None, CacheMethod m = CacheMethod.Default) { MixEntry e; if (!Index.TryGetValue(MixEntry.HashFilename(filename), out e)) { return(null); } else { return(FormatHelper.OpenAsFormat(BaseStream, filename, (int)(BaseOffset + dataStart + e.Offset), (int)e.Length, f, m)); } }
private void ParseHeader() { Position = 0; var reader = new BinaryReader(this); uint signature = reader.ReadUInt32(); bool isCncMix = (signature & 0xFFFF) != 0; bool isEncrypted = !isCncMix && (signature & (uint)MixFileFlags.Encrypted) != 0; VirtualFile header; // After next block this points to a decrypted header if (!isCncMix) { if (isEncrypted) { header = new VirtualFile(DecryptHeader(this)); } else { header = this; // implicit no seek; points at beginning of unencrypted header already } } else { // first 4 bytes already contained beginning of header, so rewind header = this; header.Seek(0, SeekOrigin.Begin); } // Now header can be parsed ushort numFiles = header.ReadUInt16(); uint dataSize = header.ReadUInt32(); Index = new Dictionary <uint, MixEntry>(numFiles); for (int i = 0; i < numFiles; i++) { var entry = new MixEntry(header.ReadUInt32(), header.ReadUInt32(), header.ReadUInt32()); Index[entry.Hash] = entry; } dataStart = this.Position; // body follows end of header }
public static MixingUpdateRequestBuilder Update(string entryId, MixEntry mixEntry) { return(new MixingUpdateRequestBuilder(entryId, mixEntry)); }
public static MixingAddRequestBuilder Add(MixEntry mixEntry) { return(new MixingAddRequestBuilder(mixEntry)); }
public bool ContainsFile(string filename) { return(Index.ContainsKey(MixEntry.HashFilename(filename))); }