示例#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
        public Cat(string filename)
        {
            /// Load directory

            byte[] catImage = File.ReadAllBytes(filename);

            int filesCount = GetEntriesCount(catImage);

            /// Load files

            for (int i = 0; i < filesCount; i++)
            {
                CatFile file = LoadCatFile(catImage, i);
                files.Add(file);
            }
        }