private void ExportAllFolder_bg(string outputPath, bool IncludeSubFolder, RhoFile file) { IPackedObject[] ipos = RhoPackedFilesInfoDecoder.GetRhoPackedFileInfos(file.GetStreamData(0xFFFFFFFF), file.HeaderKey, 0xFFFFFFFF); Stack <ExportProcessor> Stack = new Stack <ExportProcessor>(); if (!Directory.Exists(outputPath)) { throw new Exception(""); } string StartPath = ""; Stack.Push(new ExportProcessor { Path = StartPath, ipos = ipos }); while (Stack.Count > 0 && !Canceled) { ExportProcessor ep = Stack.Pop(); string outPath = outputPath + (StartPath == "" ? ep.Path : ep.Path.Replace(StartPath, "")); foreach (IPackedObject ipo in ep.ipos) { if (ipo.Type == ObjectType.Folder && IncludeSubFolder) { RhoPackedFolderInfo jpfi = (RhoPackedFolderInfo)ipo; ExportProcessor nep = new ExportProcessor { Path = ep.Path + $"\\{jpfi.FolderName}", ipos = RhoPackedFilesInfoDecoder.GetRhoPackedFileInfos(file.GetStreamData(jpfi.Index), file.HeaderKey, jpfi.Index) }; Stack.Push(nep); if (!Directory.Exists($"{outPath}\\{((RhoPackedFolderInfo)ipo).FolderName}")) { Directory.CreateDirectory($"{outPath}\\{((RhoPackedFolderInfo)ipo).FolderName}"); } continue; } if (ipo.Type == ObjectType.File) { RhoPackedFileInfo jfi = (RhoPackedFileInfo)ipo; ChangeText(label5, $"Outputing: {ep.Path}\\{jfi.FileName}.{jfi.Extension}"); FileStream fs = new FileStream($"{outPath}\\{jfi.FileName}.{jfi.Extension}", FileMode.Create); byte[] data = file.GetPackedFile(jfi); fs.Write(data, 0, data.Length); fs.Close(); data = null; } if (Canceled) { break; } } } CloseWindow(); }
public RhoFile(string path) { if (!Exists(path)) { throw new FileNotFoundException($"File:{path} can not be found."); } Path = path; FileInfo fi = new FileInfo(path); FileStream fs = new FileStream(path, FileMode.Open); BinaryReader br = new BinaryReader(fs); string FileName = fi.Extension != "" ? fi.Name.Replace(fi.Extension, "") : fi.Name; HeaderKey = KeyGenerator.GetHeaderKey(FileName); byte[] block1 = br.ReadBytes(0x80); if (!CheckFile(block1)) { throw new Exception($"File:{path} is not a correct JMDFile,check if this file is changed."); } byte[] block2 = br.ReadBytes(0x80); Header = new RhoHeader(block2, HeaderKey); HeaderKey = (BitConverter.ToUInt32(block2, 4) ^ 0x100) + 0x7b8c043f ^ 0x8473fbc1; Header = new RhoHeader(block2, HeaderKey); FixedMode = true; uint Block3Count = Header.StreamInfoCount; StreamInfos = new List <JMDStreamInfo>(); for (int i = 0; i < Block3Count; i++) { byte[] bk3 = br.ReadBytes(0x20); StreamInfos.Add(new JMDStreamInfo(bk3, Header.StreamInfosKey)); } JMDStreamInfo bk4Info = GetStreamInfo(0xFFFFFFFF); fs.Seek(bk4Info.Offset, SeekOrigin.Begin); byte[] bk4 = new byte[bk4Info.Size]; fs.Read(bk4, 0, bk4.Length); IPackedObject[] packedfileinfo = RhoPackedFilesInfoDecoder.GetMDPackedFileInfos(bk4, HeaderKey); JMDPackedFiles = packedfileinfo; fs.Close(); }
public IPackedObject[] GetInFolderObject(JMDPackedFolderInfo info) { return(RhoPackedFilesInfoDecoder.GetMDPackedFileInfos(GetStreamData(info.Index), HeaderKey)); }