Example #1
0
 /*
  * Notify single pack file having been loaded.
  */
 private void OnPackedFileLoaded(PackedFile packed)
 {
     if (this.PackedFileLoaded != null)
     {
         this.PackedFileLoaded(packed);
     }
 }
Example #2
0
        /*
         * Decode pack file at the given path.
         */
        public PackFile Open(string packFullPath)
        {
            PackFile file;
            long     sizes = 0;

            using (var reader = new BinaryReader(new FileStream(packFullPath, FileMode.Open), Encoding.ASCII)) {
                PFHeader header = ReadHeader(reader);
                file = new PackFile(packFullPath, header);
                OnHeaderLoaded(header);

                long offset = file.Header.DataStart;
                for (int i = 0; i < file.Header.FileCount; i++)
                {
                    uint size = reader.ReadUInt32();
                    sizes += size;
                    if (file.Header.HasAdditionalInfo)
                    {
                        header.AdditionalInfo = reader.ReadInt64();
                    }
                    string packedFileName = IOFunctions.ReadZeroTerminatedAscii(reader);
                    // this is easier because we can use the Path methods
                    // under both Windows and Unix
                    packedFileName = packedFileName.Replace('\\', Path.DirectorySeparatorChar);

                    PackedFile packed = new PackedFile(file.Filepath, packedFileName, offset, size);
                    file.Add(packed);
                    offset += size;
                    this.OnPackedFileLoaded(packed);
                }
            }
            this.OnFinishedLoading(file);
            file.IsModified = false;
            return(file);
        }