Beispiel #1
0
        internal static CFFILE FromStream(FileStream stream)
        {
            CFFILE       file   = new CFFILE();
            BinaryReader reader = new BinaryReader(stream);

            file.cbFile          = reader.ReadUInt32();
            file.uoffFolderStart = reader.ReadUInt32();
            file.iFolder         = reader.ReadUInt16();
            file.date            = reader.ReadUInt16();
            file.time            = reader.ReadUInt16();
            file.attribs         = (CFFILE_ATTRIBS)reader.ReadUInt16();

            List <byte> nameBytes = new List <byte>();

            while (reader.PeekChar() != 0)
            {
                nameBytes.Add(reader.ReadByte());
            }

            // move past the null terminator
            reader.ReadByte();

            byte[] byteArray = nameBytes.ToArray();
            if ((file.attribs & CFFILE_ATTRIBS.NameIsUTF) == CFFILE_ATTRIBS.NameIsUTF)
            {
                file.szName = Encoding.UTF8.GetString(byteArray, 0, byteArray.Length);
            }
            else
            {
                file.szName = Encoding.ASCII.GetString(byteArray, 0, byteArray.Length);
            }

            return(file);
        }
        public Archive(string fileName)
        {
            FileName = fileName;
            using (System.IO.FileStream stream = System.IO.File.Open(FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read))
            {
                CFHEADER header = CFHEADER.FromStream(stream);

                int dataBlocks = 0;

                for (int i = 0; i < header.CFHEADER_FIXED.cFolders; i++)
                {
                    CFFOLDER folder = CFFOLDER.FromStream(stream, header);
                    m_folders.Add(folder);

                    dataBlocks += folder.cCFData;
                }

                stream.Seek(header.CFHEADER_FIXED.coffFiles, System.IO.SeekOrigin.Begin);

                for (int i = 0; i < header.CFHEADER_FIXED.cFiles; i++)
                {
                    CFFILE file = CFFILE.FromStream(stream);
                    m_files.Add(file);
                }
                stream.Close();
            }
        }
 internal FileInfo(CFFILE file)
 {
     CFFILE = file;
 }
Beispiel #4
0
 internal void Add(CFFILE cffile)
 {
     m_files.Add(new FileInfo(cffile));
 }