예제 #1
0
        public bool BackToParentFolder()
        {
            if (NowFolder.Index == 0xFFFFFFFF)
            {
                return(false);
            }
            RhoPackedFolderInfo nowFolder = this.FolderStack.Pop();

            this.NowFolderContent = RhoPackedFilesInfoDecoder.GetRhoPackedFileInfos(GetStreamData(nowFolder.ParentIndex), this.HeaderKey, nowFolder.ParentIndex);
            this.PathStack.Pop();
            return(true);
        }
예제 #2
0
        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 RhoFile,check if this file is changed.");
            }
            byte[] block2 = br.ReadBytes(0x80);
            Header = new RhoHeader(block2, HeaderKey);
            if (!Header.IsCorrectRhoFile)
            {
                throw new Exception("It's not a correct Rho File!!!!");
            }
            uint Block3Count = Header.StreamInfoCount;

            StreamInfos = new List <RhoStreamInfo>();
            uint Block3FirstKey = KeyGenerator.GetStreamInfoFirstKey(HeaderKey);

            for (int i = 0; i < Block3Count; i++)
            {
                byte[] bk3 = br.ReadBytes(0x20);
                StreamInfos.Add(new RhoStreamInfo(bk3, Block3FirstKey));
                Block3FirstKey++;
            }
            RhoStreamInfo bk4Info = GetStreamInfo(0xFFFFFFFF);

            fs.Seek(bk4Info.Offset, SeekOrigin.Begin);
            byte[] bk4 = new byte[bk4Info.FileSize];
            fs.Read(bk4, 0, bk4.Length);
            NowFolderContent = RhoPackedFilesInfoDecoder.GetRhoPackedFileInfos(bk4, HeaderKey, 0xFFFFFFFF);
            this.FolderStack.Push(new RhoPackedFolderInfo()
            {
                FolderName  = "",
                Index       = 0xFFFFFFFF,
                ParentIndex = 0
            });
            PathStack.Push("");
            fs.Close();
        }
예제 #3
0
        public bool EnterToFolder(string FolderName)
        {
            RhoPackedFolderInfo FolderInfo = (RhoPackedFolderInfo)Array.Find(NowFolderContent, x => x.Type == ObjectType.Folder && ((RhoPackedFolderInfo)x).FolderName == FolderName);

            if (FolderName is null)
            {
                return(false);
            }
            this.ParentFolder     = this.NowFolder;
            this.NowFolderContent = RhoPackedFilesInfoDecoder.GetRhoPackedFileInfos(GetStreamData(FolderInfo.Index), this.HeaderKey, this.NowFolder.Index);
            this.FolderStack.Push(FolderInfo);
            this.PathStack.Push(FolderInfo.FolderName);
            return(true);
        }