示例#1
0
        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));
            }
        }
示例#2
0
        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
        }
示例#3
0
 public static MixingUpdateRequestBuilder Update(string entryId, MixEntry mixEntry)
 {
     return(new MixingUpdateRequestBuilder(entryId, mixEntry));
 }
示例#4
0
 public static MixingAddRequestBuilder Add(MixEntry mixEntry)
 {
     return(new MixingAddRequestBuilder(mixEntry));
 }
示例#5
0
 public bool ContainsFile(string filename)
 {
     return(Index.ContainsKey(MixEntry.HashFilename(filename)));
 }