コード例 #1
0
ファイル: Version6.cs プロジェクト: roundy7722/rpftool
        private void Add(RPFLib.Common.Directory fsDirectory, byte[] data)
        {
            FileEntry newFileEntry = new FileEntry(_rpfFile.TOC);

            _rpfFile.TOC.Add(newFileEntry as TOCEntry);

            var file = new Common.File();

            file._dataLoad   = getCustom => LoadData(newFileEntry, getCustom);
            file._dataStore  = setdata => StoreData(newFileEntry, setdata);
            file._dataCustom = () => newFileEntry.CustomData != null;
            file.d1          = () => newFileEntry.getSize();
            file._Index      = nIndex => newFileEntry.setIndex(nIndex);
            file._delete     = () => newFileEntry.Delete();

            file.CompressedSize  = newFileEntry.SizeInArchive;
            file.IsCompressed    = newFileEntry.IsCompressed;
            file.Name            = GetName(newFileEntry);
            file.IsResource      = newFileEntry.IsResourceFile;
            file.ParentDirectory = fsDirectory;
            fsDirectory.AddObject(file);

            newFileEntry.SetCustomData(data);
        }
コード例 #2
0
ファイル: Version6.cs プロジェクト: roundy7722/rpftool
        private void BuildFSDirectory(DirectoryEntry dirEntry, RPFLib.Common.Directory fsDirectory)
        {
            try
            {
                fsDirectory.Name = GetName(dirEntry);
                for (int i = 0; i < dirEntry.ContentEntryCount; i++)
                {
                    TOCEntry entry = _rpfFile.TOC[dirEntry.ContentEntryIndex + i];
                    if (entry.IsDirectory)
                    {
                        var subdirEntry = entry as DirectoryEntry;
                        var dir         = new RPFLib.Common.Directory();
                        dir._Contentcount   = nCount => subdirEntry.setContentcount(nCount);
                        dir._ContentIndex   = ContentIndex => subdirEntry.setContentIndex(ContentIndex);
                        dir._Index          = NewContentIndex => subdirEntry.setNewContentIndex(NewContentIndex);
                        dir.nameHash        = (uint)subdirEntry.NameOffset;
                        dir.ParentDirectory = fsDirectory;
                        dir.Attributes      = "Folder";
                        BuildFSDirectory(entry as DirectoryEntry, dir);
                        fsDirectory.AddObject(dir);
                    }
                    else
                    {
                        var fileEntry = entry as FileEntry;
                        var file      = new Common.File();
                        file._dataLoad   = getCustom => LoadData(fileEntry, getCustom);
                        file._dataStore  = data => StoreData(fileEntry, data);
                        file._dataCustom = () => fileEntry.CustomData != null;
                        file.d1          = () => fileEntry.getSize();
                        file._Index      = nIndex => fileEntry.setIndex(nIndex);
                        file._delete     = () => fileEntry.Delete();

                        file.CompressedSize  = fileEntry.SizeInArchive;
                        file.IsCompressed    = fileEntry.IsCompressed;
                        file.nameHash        = (uint)fileEntry.NameOffset;
                        file.Name            = GetName(fileEntry);
                        file.IsResource      = fileEntry.IsResourceFile;
                        file.resourcetype    = (int)fileEntry.ResourceType;//Convert.ToString((ResourceType)fileEntry.ResourceType);
                        file.ParentDirectory = fsDirectory;

                        StringBuilder attributes = new StringBuilder();
                        if (file.IsResource)
                        {
                            attributes.Append(string.Format("Resource [Version {0}", fileEntry.ResourceType));
                            if (file.IsCompressed)
                            {
                                attributes.Append(", Compressed");
                            }
                            attributes.Append("]");
                        }
                        else if (file.IsCompressed)
                        {
                            attributes.Append("Compressed");
                        }
                        else
                        {
                            attributes.Append("None");
                        }
                        file.Attributes = attributes.ToString();
                        fsDirectory.AddObject(file);
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }