コード例 #1
0
        /// Load file

        private CatFile LoadCatFile(byte[] catImage, int entryNum)
        {
            CatFile file = new CatFile();

            CatDirEntry entry = GetDirEntry(catImage, entryNum);

            file.hash = entry.hash;
            file.data = new byte[entry.size];

            for (int i = 0; i < entry.size; i++)
            {
                file.data[i] = catImage[entry.fileOffset + i];
            }
            int offset = 8;

            while (file.data[offset] != 0 && file.data[offset] != 2)
            {
                file.name += (char)file.data[offset];
                offset++;
            }
            if (file.name[0] == 'c' || file.name[0] == 'C')
            {
                file.name = file.name.Substring(1);
            }


            return(file);
        }
コード例 #2
0
        /// Get Direntry

        private CatDirEntry GetDirEntry(byte[] catImage, int entryNum)
        {
            CatDirEntry entry = new CatDirEntry();

            int entryOffset = entryNum * 12 + 4;

            entry.hash       = GetDword(catImage, entryOffset);
            entry.fileOffset = GetDword(catImage, entryOffset + 4);
            entry.size       = GetDword(catImage, entryOffset + 8);

            return(entry);
        }