Ejemplo n.º 1
0
        public static BigArchive FromBytes(byte[] data, Action <string> writeLog = null)
        {
            if (writeLog == null)
            {
                writeLog = NullLogger.Write;
            }

            BigArchive bf = new BigArchive();

            //load global header
            bf.GlobalHeader = GlobalHeader.FromBytes(data);
            writeLog("header loaded...");

            //load the index
            FileIndex fi = FileIndex.FromBytes(data, bf.GlobalHeader);

            writeLog("index loaded...");

            //there's some junk after the index: "L225" or "L231" plus 4 or 5 bytes of padding
            //Music.big also has some weird junk in between the end of the index and the mystery junk, but I'm not sure if it's intended or not
            //we can probably ignore that when loading but not when saving
            //we will probably just try "L231" plus four bytes at least initially

            //load files from index
            writeLog("\nloading files");
            foreach (var indexEntry in fi.Entries)
            {
                byte[] fileData = data[(int)indexEntry.DataPosition..(int)(indexEntry.DataPosition + indexEntry.DataSize)];