Example #1
0
        public void Extract(ref Dictionary <string, FileStream> streamCache, string destinationFolder, bool extractAsRaw)
        {
            string destinationFile = Path.Combine(Path.Combine(destinationFolder, this.ParentDirectoryName), this.FileName);

            byte[] magicBytes;

            if (!streamCache.ContainsKey(this.SourceFilePath))
            {
                streamCache[this.SourceFilePath] = File.OpenRead(this.SourceFilePath);
            }

            // check for CRILAYLA signature since file size is not always reliable,
            //    this will be a little slower, but hopefully the stream caching will minimize
            //    the impact
            magicBytes = ParseFile.ParseSimpleOffset(streamCache[this.SourceFilePath], (long)this.Offset, CriCpkArchive.CRILAYLA_SIGNATURE.Length);

            if (ParseFile.CompareSegment(magicBytes, 0, CriCpkArchive.CRILAYLA_SIGNATURE))
            {
                CriCpkArchive.Uncompress(streamCache[this.SourceFilePath], (long)this.Offset, this.Size, destinationFile);
            }
            else
            {
                ParseFile.ExtractChunkToFile64(streamCache[this.SourceFilePath], (ulong)this.Offset, (ulong)this.Size, destinationFile, false, false);
            }
        }
Example #2
0
        public CriAcbFile(FileStream fs, long offset, bool includeCueIdInFileName)
        {
            // initialize UTF
            this.Initialize(fs, offset);

            // initialize ACB specific items
            this.InitializeCueList(fs);
            this.InitializeCueNameToWaveformMap(fs, includeCueIdInFileName);

            // initialize internal AWB
            if (this.InternalAwbFileSize > 0)
            {
                if (CriAfs2Archive.IsCriAfs2Archive(fs, (long)this.InternalAwbFileOffset))
                {
                    this.InternalAwb = new CriAfs2Archive(fs, (long)this.InternalAwbFileOffset);
                }
                else if (CriCpkArchive.IsCriCpkArchive(fs, (long)this.InternalAwbFileOffset))
                {
                    this.InternalCpk = new CriCpkArchive();
                    this.InternalCpk.Initialize(fs, (long)this.InternalAwbFileOffset, true);
                }
            }

            // initialize external AWB

            // @TODO: This isn't correct for files with CPKs
            if ((this.StreamAwbAfs2HeaderSize > 0) ||
                (!ByteConversion.IsZeroFilledByteArray(this.StreamAwbHash)))
            {
                // get external file name
                this.StreamfilePath = this.GetStreamfilePath();

                // get file type
                using (FileStream awbFs = File.Open(this.StreamfilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    // AWB
                    if (CriAfs2Archive.IsCriAfs2Archive(awbFs, 0))
                    {
                        this.ExternalAwb = new CriAfs2Archive(awbFs, 0);
                    }
                    // CPK
                    else if (CriCpkArchive.IsCriCpkArchive(awbFs, 0))
                    {
                        this.ExternalCpk = new CriCpkArchive();
                        this.ExternalCpk.Initialize(awbFs, 0, true);
                    }
                }
            }
        }