Пример #1
0
        /// <summary>
        /// Unpack a PBP file, avoiding to consume too much memory
        /// (i.e. not reading each section completely in memory).
        /// </summary>
        /// <param name="vFile">        the PBP file </param>
        /// <exception cref="IOException"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static void unpackPBP(pspsharp.HLE.VFS.IVirtualFile vFile) throws java.io.IOException
        public static void unpackPBP(IVirtualFile vFile)
        {
            vFile.ioLseek(0L);
            PBP pbp = new PBP();

            pbp.size_pbp = (int)vFile.Length();
            pbp.p_magic  = read32(vFile);
            if (!pbp.Valid)
            {
                return;
            }
            pbp.p_version = read32(vFile);
            pbp.p_offsets = new int[] { read32(vFile), read32(vFile), read32(vFile), read32(vFile), read32(vFile), read32(vFile), read32(vFile), read32(vFile), pbp.size_pbp };

            File dir = new File(PBP_UNPACK_PATH_PREFIX);

            deleteDir(dir);             //delete all files and directory
            dir.mkdir();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'sealed override':
//ORIGINAL LINE: sealed override byte[] buffer = new byte[10 * 1024];
            sbyte[] buffer = new sbyte[10 * 1024];
            for (int index = 0; index < TOTAL_FILES; index++)
            {
                int size = pbp.getSize(index);
                if (size > 0)
                {
                    long offset = pbp.getOffset(index) & 0xFFFFFFFFL;
                    if (vFile.ioLseek(offset) == offset)
                    {
                        System.IO.Stream os = new System.IO.FileStream(PBP_UNPACK_PATH_PREFIX + pbp.getName(index), System.IO.FileMode.Create, System.IO.FileAccess.Write);
                        while (size > 0)
                        {
                            int Length     = System.Math.Min(size, buffer.Length);
                            int readLength = vFile.ioRead(buffer, 0, Length);
                            if (readLength > 0)
                            {
                                os.Write(buffer, 0, readLength);
                                size -= readLength;
                            }
                            if (readLength != Length)
                            {
                                break;
                            }
                        }
                        os.Close();
                    }
                }
            }
        }
Пример #2
0
        public PartialVirtualFile(IVirtualFile vFile, long startPosition, long Length) : base(vFile)
        {
            this.startPosition  = startPosition;
            this.length_Renamed = Length;

            vFile.ioLseek(startPosition);
        }
Пример #3
0
        protected internal override bool isHeaderValid(IVirtualFile pgdFile)
        {
            sbyte[] header   = new sbyte[edatHeaderSize];
            long    position = pgdFile.Position;
            int     Length   = pgdFile.ioRead(header, 0, edatHeaderSize);

            pgdFile.ioLseek(position);

            if (Length != edatHeaderSize)
            {
                return(false);
            }

            if (header[0] != 0 || header[1] != (sbyte)'P' || header[2] != (sbyte)'S' || header[3] != (sbyte)'P' || header[4] != (sbyte)'E' || header[5] != (sbyte)'D' || header[6] != (sbyte)'A' || header[7] != (sbyte)'T')
            {
                // No "EDAT" found in the header,
                Console.WriteLine("PSPEDAT header not found!");
                return(false);
            }

            return(base.isHeaderValid(pgdFile));
        }
Пример #4
0
        private void init(sbyte[] key, IVirtualFile pgdFile, int dataOffset)
        {
            isValid = false;

            long position = pgdFile.Position;

            if (isHeaderValid(pgdFile))
            {
                PGDBlockVirtualFile pgdBlockFile = new PGDBlockVirtualFile(pgdFile, key, dataOffset);

                isHeaderPresent = pgdBlockFile.HeaderPresent;
                if (pgdBlockFile.HeaderValid)
                {
                    setBufferedVirtualFile(pgdBlockFile, pgdBlockFile.BlockSize);
                    isValid = true;
                }
            }

            if (!isValid)
            {
                pgdFile.ioLseek(position);
                setBufferedVirtualFile(pgdFile, 0x1000);
            }
        }
Пример #5
0
 public virtual long ioLseek(IVirtualFile file, long offset)
 {
     return(file.ioLseek(offset));
 }
Пример #6
0
 public virtual long ioLseek(long offset)
 {
     return(vFile.ioLseek(offset));
 }