public static D2pEntry CreateEntryDefinition(D2pFile container, IDataReader reader) { var entry = new D2pEntry(container); entry.ReadEntryDefinition(reader); return(entry); }
public D2pEntry(D2pFile container, string fileName, byte[] data) { Container = container; FullFileName = fileName; m_newData = data; State = D2pEntryState.Added; Size = data.Length; Index = -1; }
private bool InternalRemoveLink(D2pFile link) { if (m_links.Remove(link)) { OnPropertyChanged("Links"); return(true); } return(false); }
public void Save() { if (!HasFilePath()) { throw new InvalidOperationException("Cannot perform Save : No path defined, use SaveAs instead"); } lock (m_linksToSave) { // save the links before while (m_linksToSave.Count > 0) { D2pFile link = m_linksToSave.Dequeue(); // theorically the path is defined link.Save(); } } if (m_fileStream != null) { var tempPath = Path.GetTempFileName(); var tempStream = File.Create(tempPath); InternalSave(tempStream); tempStream.Close(); m_reader.Dispose(); File.Delete(FilePath); File.Move(tempPath, FilePath); m_reader = new BigEndianReader(m_fileStream = File.OpenRead(FilePath)); } else { using (var stream = File.OpenWrite(FilePath)) { InternalSave(stream); } m_reader = new FastBigEndianReader(File.ReadAllBytes(FilePath)); } }
private void InternalAddLink(string linkFile) { string path = GetLinkFileAbsolutePath(linkFile); if (!File.Exists(path)) { throw new FileNotFoundException(linkFile); } var link = new D2pFile(path); foreach (D2pEntry entry in link.Entries) { InternalAddEntry(entry); } m_links.Add(link); OnPropertyChanged("Links"); }
public bool RemoveLink(D2pFile file) { D2pProperty property = m_properties.FirstOrDefault(entry => Path.GetFullPath(GetLinkFileAbsolutePath(entry.Value)) == Path.GetFullPath(file.FilePath)); if (property == null) { return(false); } bool result = InternalRemoveLink(file) && m_properties.Remove(property); if (result) { OnPropertyChanged("Properties"); } return(result); }
public bool RemoveProperty(D2pProperty property) { if (property.Key == "link") { D2pFile link = m_links.FirstOrDefault(entry => Path.GetFullPath(GetLinkFileAbsolutePath(property.Value)) == Path.GetFullPath(entry.FilePath)); if (link == null || !InternalRemoveLink(link)) { throw new Exception(string.Format("Cannot remove the associated link {0} to this property", property.Value)); } } if (m_properties.Remove(property)) { OnPropertyChanged("Properties"); IndexTable.PropertiesCount--; return(true); } return(false); }
public D2pEntry(D2pFile container, string fileName) { Container = container; FullFileName = fileName; Index = -1; }
private D2pEntry(D2pFile container) { Container = container; Index = -1; }
public D2pIndexTable(D2pFile container) { Container = container; }
public D2pDirectory(D2pFile container, string name) { Container = container; Name = name; FullName = name; }