示例#1
0
        public void RemoveItem(VirtualFileSystemInfo vfsi)
        {
            var filesList = GetFiles().ToList();

            filesList.Remove(vfsi);
            RebuildPACData(filesList.ToArray(), FileNameLength);
        }
示例#2
0
        public VirtualFileSystemInfo[] GetFiles(bool recheck = false)
        {
            if (!Initialized)
            {
                Initialize();
                InitGetHeader();
            }

            try
            {
                if (FileCount <= 0)
                {
                    return(new VirtualFileSystemInfo[0]);
                }

                if (Files != null && !recheck)
                {
                    return(Files);
                }

                using (var reader = new EndiannessAwareBinaryReader(GetReadStream(), Endianness))
                {
                    ReadHeaderInfo(reader);

                    var virtualFiles = new VirtualFileSystemInfo[FileCount];

                    for (var i = 0; i < FileCount; i++)
                    {
                        var fileName = Encoding.ASCII
                                       .GetString(reader.ReadBytes(FileNameLength, ByteOrder.LittleEndian))
                                       .Replace("\0", string.Empty);
                        var fileIndex  = reader.ReadUInt32();
                        var fileOffset = reader.ReadUInt32();
                        var fileLength = reader.ReadUInt32();
                        var seeklength = (FileNameLength + 12) % 16;
                        reader.BaseStream.Seek(seeklength == 0 ? seeklength : 16 - seeklength, SeekOrigin.Current);
                        if (reader.ReadByte() == 0x0 && seeklength == 0)
                        {
                            reader.BaseStream.Seek(16, SeekOrigin.Current);
                        }
                        reader.BaseStream.Seek(-1, SeekOrigin.Current);
                        var ext = Path.GetExtension(fileName);
                        switch (ext)
                        {
                        case ".pac":
                        case ".paccs":
                        case ".pacgz":
                        case ".fontpac":
                            virtualFiles[i] = new PACFileInfo(
                                FullName + ':' + fileName,
                                fileLength,
                                fileOffset + HeaderSize,
                                this);
                            break;

                        case ".hip":
                            virtualFiles[i] = new HIPFileInfo(
                                FullName + ':' + fileName,
                                fileLength,
                                fileOffset + HeaderSize,
                                this);
                            break;

                        case ".hpl":
                            virtualFiles[i] = new HPLFileInfo(
                                FullName + ':' + fileName,
                                fileLength,
                                fileOffset + HeaderSize,
                                this);
                            break;

                        case ".dds":
                            virtualFiles[i] = new DDSFileInfo(
                                FullName + ':' + fileName,
                                fileLength,
                                fileOffset + HeaderSize,
                                this);
                            break;

                        default:
                            virtualFiles[i] = new VirtualFileSystemInfo(
                                FullName + ':' + fileName,
                                fileLength,
                                fileOffset + HeaderSize,
                                this);
                            break;
                        }
                    }

                    reader.Close();

                    Files = virtualFiles;
                    return(Files);
                }
            }
            catch
            {
                Files = new VirtualFileSystemInfo[0];
                return(Files);
            }
        }