/// <summary> /// Imports a file. /// </summary> public void Import(IArchiveDirectory directory, string fileName) { var fi = new FileInfo(fileName); var fs = new FileStream(fileName, FileMode.Open); var fsR = new DataReader(fs); var ident = fsR.ReadUInt32(); fs.Close(); // delete existing file var existingFile = directory.GetFile(fi.Name); if (existingFile != null) { directory.DeleteFile(existingFile); } if (ident == 0x07435352) { var newF = directory.CreateResourceFile(); newF.Name = fi.Name; newF.Import(fileName); } else { var newF = directory.CreateBinaryFile(); newF.Name = fi.Name; newF.Import(fileName); } }
/// <summary> /// Imports a file. /// </summary> public void Import(IArchiveDirectory directory, string fileName) { var fi = new FileInfo(fileName); var fs = new FileStream(fileName, FileMode.Open); var fsR = new DataReader(fs); var ident = fsR.ReadUInt32(); fs.Close(); // delete existing file var existingFile = directory.GetFile(fi.Name); if (existingFile != null) directory.DeleteFile(existingFile); if (ident == 0x07435352) { var newF = directory.CreateResourceFile(); newF.Name = fi.Name; newF.Import(fileName); } else { var newF = directory.CreateBinaryFile(); newF.Name = fi.Name; newF.Import(fileName); } }
private void Handle(IArchiveDirectory root, RpfListBuilder.InnerFile file, string name) { switch (file.Action) { case ContentAction.Delete: var archiveFile = root.GetFile(name); if (archiveFile != null) root.DeleteFile(archiveFile); break; case ContentAction.Import: { if (!_config.TreatImportsAsInserts) break; NewImport(root, file, file.FilePath, name); break; } case ContentAction.Insert: { NewImport(root, file, file.FilePath, name); break; } } }
private static void NewImport(IArchiveDirectory root, RpfListBuilder.IFileContent fc, IAbsoluteFilePath tmpRpf, string name) { var existingFile = root.GetFile(name); var af = root.CreateArchiveFile(tmpRpf.ToString(), fc.Type == FileType.Default && existingFile != null ? DetermineType(existingFile) : fc.Type); if (existingFile != null) root.DeleteFile(existingFile); //af.IsCompressed = true; af.Name = name; af.Import(tmpRpf.ToString()); }