Esempio n. 1
0
        public byte[] GetFile(DirTreeEntry entry)
        {
            byte[] result = new byte[entry.PackedSize];

            FileStream fileStream = new FileStream(datFileName, FileMode.Open);

            fileStream.Seek(entry.Offset, SeekOrigin.Begin);
            fileStream.Read(result, 0, entry.PackedSize);

            fileStream.Close();

            if (entry.IsCompressed)
            {
                return(DecompressFile(result, entry.RealSize));
            }

            return(result);
        }
Esempio n. 2
0
        public DatFile(string fileName)
        {
            datFileName = fileName;
            fileStream  = new FileStream(datFileName, FileMode.Open);
            GetFileData();
            archiveFullSize = GetArchiveFullSize();
            treeSize        = GetTreeSize();
            dirTreeOffset   = fileLength - treeSize - 4;
            filesTotal      = GetFilesTotal();
            currentOffset   = dirTreeOffset;
            for (int i = 0; i < filesTotal; i++)
            {
                entry = GetTreeEntry(currentOffset);
                entries.Add(entry);
                currentOffset = entry.EndOffset;
            }

            fileStream.Close();
        }
Esempio n. 3
0
        private DirTreeEntry GetTreeEntry(int offset)
        {
            DirTreeEntry result = new DirTreeEntry();

            result.FileNameSize = GetDwordValue(offset);

            offset             += 4;
            result.FileName     = GetStringValue(offset, result.FileNameSize);
            offset             += result.FileNameSize;
            result.IsCompressed = Convert.ToBoolean(GetByteValue(offset));
            offset             += 1;
            result.RealSize     = GetDwordValue(offset);
            offset             += 4;
            result.PackedSize   = GetDwordValue(offset);
            offset             += 4;
            result.Offset       = GetDwordValue(offset);
            result.EndOffset    = offset + 4;

            return(result);
        }