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.Attributes = "Folder"; //dir.entryNum = dirEntry.ContentEntryIndex + i; dir.ParentDirectory = fsDirectory; 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.entryNum = dirEntry.ContentEntryIndex + i; file.CompressedSize = fileEntry.SizeInArchive; file.IsCompressed = fileEntry.IsCompressed; file.Name = GetName(fileEntry); //file.Size = fileEntry.Size; file.IsResource = fileEntry.IsResourceFile; 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"); fsDirectory.AddObject(file); } } } catch (System.Exception ex) { MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace); } }
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); }