public static Animation Load(IArchiveFile animationFile) { string label = Path.GetFileNameWithoutExtension(animationFile.Name); List <Pose> posesByFrame = Persistance.Load <List <Pose> >(animationFile); return(new Animation(label, posesByFrame)); }
public void FillList(IArchiveFile file) { archiveFile = file; UpdateFiles(); treeViewCustom1.BeginUpdate(); treeViewCustom1.Nodes.Clear(); if (Files.Count > 0) { var lookup = Files.OrderBy(f => f.FileName.TrimStart('/', '\\')).ToLookup(f => System.IO.Path.GetDirectoryName(f.FileName.TrimStart('/', '\\'))); // Build directory tree var root = treeViewCustom1.Nodes.Add("root", ((IFileFormat)file).FileName, "tree-archive-file", "tree-archive-file"); foreach (var dir in lookup.Select(g => g.Key)) { dir.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries) .Aggregate(root, (node, part) => node.Nodes[part] ?? node.Nodes.Add(part, part)) .Tag = lookup[dir]; } root.Expand(); treeViewCustom1.SelectedNode = root; } treeViewCustom1.EndUpdate(); }
public void LoadFile(ObjectView parent, ArchiveFileInfo archiveFileInfo, IArchiveFile archiveFile) { ParentObjectView = parent; ArchiveFileInfo = archiveFileInfo; ArchiveFile = archiveFile; UpdateEditor(); }
public void CopyVfsSubtree(IArchiveFile subTree, string baseDirectory, bool excludeRootNode) { if (subTree == null) { return; } if (FileSystem.Current.DirectoryExists(baseDirectory)) { if (excludeRootNode) { foreach (var file in subTree.Children.Values) { bool cancel = CopyVfsSubtreeRecursive(file, baseDirectory); if (cancel) { break; } } } else { CopyVfsSubtreeRecursive(subTree, baseDirectory); } } else { throw new Exception("base directory does not exist"); } }
//Create a combination of all the archive files in multiple archives //All files in this list are supported formats public List <ArchiveFileInfo> OpenFileFormats(IArchiveFile ArchiveFile) { var Files = new List <ArchiveFileInfo>(); foreach (var file in ArchiveFile.Files) { if (file.FileFormat == null) { file.FileFormat = file.OpenFile(); if (file.FileFormat != null) { if (file.FileFormat is IArchiveFile) { return(OpenFileFormats((IArchiveFile)file.FileFormat)); } else { Files.Add(file); } } } else { Files.Add(file); } } return(Files); }
public ArchiveFileWrapper(string text, ArchiveFileInfo archiveFileInfo, IArchiveFile archiveFile) : base(archiveFile) { Text = text; ReloadMenus(archiveFile); ArchiveFileInfo = archiveFileInfo; if (archiveFileInfo.FileData != null) { string Extension = FindMatch(archiveFileInfo.FileData); switch (Extension) { case ".bntx": SetImageKey("bntx"); break; case ".byaml": SetImageKey("byaml"); break; case ".aamp": SetImageKey("aamp"); break; case ".bfres": SetImageKey("bfres"); break; case ".sbfres": SetImageKey("sbfres"); break; default: SetImageKey("fileBlank"); break; } } }
public void LoadArchive(IArchiveFile archiveFile, string fileName) { TreeNode currentNode = new TreeNode(); TreeNode root = new TreeNode(fileName); treeView1.Nodes.Add(root); foreach (var file in archiveFile.Files) { currentNode = null; string nodeString = file.FileName; var roots = nodeString.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); var parentNode = root; var sb = new System.Text.StringBuilder(fileName, nodeString.Length + fileName.Length); for (int rootIndex = 0; rootIndex < roots.Length; rootIndex++) { // Build the node name var parentName = roots[rootIndex]; sb.Append("/"); sb.Append(parentName); var nodeName = sb.ToString(); // Search for the node var index = parentNode.Nodes.IndexOfKey(nodeName); if (index == -1) { var folder = new TreeNode(parentName) { Name = nodeName, Checked = true, }; if (rootIndex == roots.Length - 1) { var fileNode = new TreeNode(parentName) { Name = nodeName, Checked = true, }; parentNode.Nodes.Add(fileNode); parentNode = fileNode; } else { parentNode.Nodes.Add(folder); parentNode = folder; } } else { parentNode = parentNode.Nodes[index]; } } } root.ExpandAll(); }
public ArchiveHiearchy(IArchiveFile archiveFile, ObjectTreeNode node) { if (node.Tag is ArchiveFileInfo) { ArchiveFileInfo = (ArchiveFileInfo)node.Tag; } ArchiveFile = archiveFile; ReferenceNode = node; Label = node.Label; Tag = node.Tag; ImageKey = node.ImageKey; if (node.ChildCount > 0) { ImageKey = "Folder"; Children.Add(new ObjectTreeNode("dummy")); } if (ArchiveFileInfo != null) { foreach (var loader in FileManager.GetFileIconLoaders()) { string key = loader.Identify(Label, ArchiveFileInfo.FileData); if (key != string.Empty) { ImageKey = key; } } } }
public void AddArchive(IArchiveFile archive) { if (!PartArchives.ContainsKey(((IFileFormat)archive).FileName)) { PartArchives.Add(((IFileFormat)archive).FileName, archive); } }
public IOccluder Load(IArchiveDirectory occlusionDirectory) { bool isMainFigure = channelSystem.Parent == null; if (isMainFigure) { IArchiveFile occluderParametersFile = occlusionDirectory.File("occluder-parameters.dat"); if (occluderParametersFile == null) { throw new InvalidOperationException("expected main figure to have occlusion system"); } var occluderParameters = Persistance.Load <OccluderParameters>(occluderParametersFile); OcclusionInfo[] unmorphedOcclusionInfos = OcclusionInfo.UnpackArray(unmorphedOcclusionDirectory.File("occlusion-infos.array").ReadArray <uint>()); var occluder = new DeformableOccluder(device, shaderCache, channelSystem, unmorphedOcclusionInfos, occluderParameters); return(occluder); } else { OcclusionInfo[] figureOcclusionInfos = OcclusionInfo.UnpackArray(occlusionDirectory.File("occlusion-infos.array").ReadArray <uint>()); OcclusionInfo[] parentOcclusionInfos = OcclusionInfo.UnpackArray(occlusionDirectory.File("parent-occlusion-infos.array").ReadArray <uint>()); var occluder = new StaticOccluder(device, figureOcclusionInfos, parentOcclusionInfos); return(occluder); } }
public Entry(TextureCache loader, IArchiveFile key, ShaderResourceView resource) { this.loader = loader; this.key = key; this.resource = resource; referenceCount = 0; }
public static void AddFiles(TreeNode parentNode, IArchiveFile archiveFile, string[] Files) { if (Files == null || Files.Length <= 0 || !archiveFile.CanAddFiles) { return; } for (int i = 0; i < Files.Length; i++) { var File = ArchiveFileWrapper.FromPath(Files[i], archiveFile); string FileName = Path.GetFileName(Files[i]); //Don't add the root file name if (parentNode.FullPath != string.Empty || !(parentNode is ArchiveRootNodeWrapper)) { File.ArchiveFileInfo.FileName = Path.Combine(parentNode.FullPath, FileName); } else { File.ArchiveFileInfo.FileName = FileName; } bool HasAddedFile = archiveFile.AddFile(File.ArchiveFileInfo); if (HasAddedFile) { parentNode.Nodes.Add(File); } } }
//when loaded from an install package public Game(IArchiveFile gameFile) : base(gameFile) { if (ErrorCollection.Count == 0) { LoadImageFromArchive(gameFile); } }
public ArchiveFolderNodeWrapper(string text, IArchiveFile archiveFile) : base(archiveFile) { Text = text; PropertyDisplay = new GenericFolderProperties(); ((GenericFolderProperties)PropertyDisplay).Name = Text; ReloadMenus(archiveFile); }
public static ArchiveFileWrapper FromPath(string FilePath, IArchiveFile archiveFile) { var ArchiveFileInfo = new ArchiveFileInfo(); ArchiveFileInfo.FileName = FilePath; ArchiveFileInfo.FileData = File.ReadAllBytes(FilePath); return(new ArchiveFileWrapper(Path.GetFileName(FilePath), ArchiveFileInfo, archiveFile)); }
private static ShaderResourceView LoadTexture(Device device, IArchiveFile file) { using (var dataView = file.OpenDataView()) { DdsLoader.CreateDDSTextureFromMemory(device, dataView.DataPointer, out Resource texture, out ShaderResourceView view); texture.Dispose(); return(view); } }
private ShaderResourceView Load(IArchiveFile file) { using (var dataView = file.OpenDataView()) { DdsLoader.CreateDDSTextureFromMemory(device, dataView.DataPointer, out var texture, out var textureView); texture.Dispose(); return(textureView); } }
private Entry AddEntry(IArchiveFile key) { //Console.WriteLine($"loading {key.Name}"); ShaderResourceView resource = Load(key); var entry = new Entry(this, key, resource); dict.Add(key, entry); return(entry); }
public void CopyVfsFile(IArchiveFile vfsFile, string filename) { if (vfsFile == null) { return; } CopyVfsFileInternal(vfsFile, filename); }
/// <summary> /// Removes the current file. /// </summary> /// <param name="file">File to remove.</param> public static bool Remove(this IArchiveFile file) { if (file.Parent is IArchiveDirectory directory) { return(directory.RemoveFile(file.Name)); } return(false); }
public Archive(ZipFile file, IArchiveFile parent, string name) { Parent = parent; Name = name; IsFolder = true; _file = file; Children = new Dictionary <string, IArchiveFile>(); }
/// <summary> /// Deletes an existing file inside this directory. /// </summary> public void DeleteFile(IArchiveFile file) { var found = this.directory.Files.Find(e => e.Name == file.Name); if (found != null) { this.directory.Files.Remove(found); } }
public Task(Main aOwner, ArchiveItem aItem, FileInfo aFile, Guid aFormat, ThreadIOPriority aPriority) { file = new ArchiveFile(aFile, aFormat, aPriority); item = aItem; owner = aOwner; file.ExtractFile += OnExtractFile; file.ExtractProgress += OnExtractProgress; file.PasswordAttempt += OnPasswordAttempt; }
internal ProjectResourceImporter(ProjectExplorer projectExplorer, ProjectDirectory directory, IArchiveFile archiveEntry, string projectKey) { ProjectExplorer = projectExplorer; Directory = directory; ArchiveEntry = archiveEntry; ProjectKey = projectKey; ImporterTags = new HashSet <string>(); Dependencies = new ProjectResourceImporterDependencyCollection(this); }
public Archive(ZipFile file, IArchiveFile parent, string name, ZipEntry entry) { Parent = parent; Name = name; IsFolder = false; _entry = entry; _file = file; Children = new Dictionary <string, IArchiveFile>(); }
public static SubTreeData GetSubTreeData(IArchiveFile vfsSubtree) { var result = new SubTreeData(); if (vfsSubtree != null) { GetSubTreeDataRecursive(vfsSubtree, result); } return(result); }
public SharedTexture Get(IArchiveFile file) { lock (this) { if (!dict.TryGetValue(file, out var cacheEntry)) { cacheEntry = AddEntry(file); } return(new SharedTexture(cacheEntry)); } }
/// <summary> /// Should we exclude this entry? /// </summary> private bool ExcludeEntry(Project project, IArchiveFile entry) { if (entry.FullPath.EndsWith(".project") && !entry.FullPath.EndsWith($"{project.Name}/.project")) { return(true); } return(false); }
public static SubTreeData GetSubTreeData(IArchiveFile vfsSubtree) { var result = new SubTreeData(); if (vfsSubtree != null) { GetSubTreeDataRecursive(vfsSubtree, result); } return result; }
private static void WriteJsonDocument(IArchiveFile entry, object value) { using var zipStream = entry.OpenWrite(); using var sr = new StreamWriter(zipStream); using var writer = new JsonTextWriter(sr); var serializer = new JsonSerializer(); serializer.Serialize(writer, value); }
static NodeBase CreateObjectHiearchy(NodeBase parent, IArchiveFile archiveFile) { // build a TreeNode collection from the file list foreach (var file in archiveFile.Files) { string[] paths = file.FileName.Split('/'); ProcessTree(parent, file, paths, 0); } return(parent); }
public MockArchiveFile(IArchiveFile parent,string name) { Parent = parent; Name = name; IsFolder = true; Children = new Dictionary<string, IArchiveFile>(); if (parent!=null) { parent.Children.Add(name.ToLowerInvariant(), this); } }
/// <summary> /// Returns the file's contents, with any applicable /// transformations applied. /// </summary> public byte[] GetFileContents( Project project, ClassroomMembership student, IArchiveFile entry) { if (entry.FullPath.EndsWith(".project")) { var newContents = entry.GetEncodedData().Replace ( $"<name>{project.Name}</name>", $"<name>{project.Name}_{student.GitHubTeam}</name>" ); using (var memoryStream = new MemoryStream()) using (var streamWriter = new StreamWriter(memoryStream)) { streamWriter.Write(newContents); streamWriter.Flush(); return memoryStream.ToArray(); } } else if (entry.FullPath.EndsWith(".classpath")) { var jUnitPath = "org.eclipse.jdt.junit.JUNIT_CONTAINER/4"; using (var stream = new MemoryStream(entry.GetRawData())) { var projectNode = XElement.Load(stream); var hasJUnit = projectNode .Elements(XName.Get("classpathentry")) .Any ( elt => elt.Attribute(XName.Get("path")) != null && elt.Attribute(XName.Get("path")).Value == jUnitPath ); if (!hasJUnit) projectNode.Add(XElement.Parse($"<classpathentry kind=\"con\" path=\"{jUnitPath}\"/>")); using (var newStream = new MemoryStream()) { projectNode.Save(newStream); newStream.Flush(); return newStream.ToArray(); } } } else { return entry.GetRawData(); } }
private static void GetSubTreeDataRecursive(IArchiveFile vfsSubtree, SubTreeData data) { if (vfsSubtree.IsFolder) { foreach (var file in vfsSubtree.Children.Values) { GetSubTreeDataRecursive(file, data); } } else { data.FileCount++; data.BytesCount += vfsSubtree.Size; } }
public MockArchiveFile(IArchiveFile parent,string name,string data) { Parent = parent; Name = name; IsFolder = false; _data = data; Children= new Dictionary<string, IArchiveFile>(); Size = data.Length; if (parent != null) { parent.Children.Add(name.ToLowerInvariant(), this); } }
public Update(Game upgadeTarget, IArchiveFile updateFile) : base(updateFile) { _updateTarget = upgadeTarget; if (UpdateMinVersion >= upgadeTarget.Version || UpdateMaxVersion >= upgadeTarget.Version) { ErrorCollection.Add("UpdateMinVersion and UpdateMaxVersion must be less than the upgraded game version"); } else if (UpdateMinVersion > UpdateMaxVersion) { ErrorCollection.Add("UpdateMinVersion must be less than or equal to UpdateMaxVersion"); } }
protected JsonEntity(IArchiveFile file) { try { using (var stream = file.OpenStream()) { using (var reader = new StreamReader(stream)) { var json = JObject.Parse(reader.ReadToEnd()); DoLoad(json); } } } catch (Exception ex) { _errorCollection.Add("Unable to load data from " + file.Name + " - " + ex); Logger.Current.Write(ex, "Unable to load data from " + file.Name); } }
public void CopyVfsSubtree(IArchiveFile subTree, string baseDirectory, bool excludeRootNode) { if (subTree == null) return; if (FileSystem.Current.DirectoryExists(baseDirectory)) { if (excludeRootNode) { foreach (var file in subTree.Children.Values) { bool cancel = CopyVfsSubtreeRecursive(file,baseDirectory); if (cancel) break; } } else { CopyVfsSubtreeRecursive(subTree, baseDirectory); } } else { throw new Exception("base directory does not exist"); } }
/// <summary> /// Exports a file. /// </summary> public void Export(IArchiveFile file, string fileName) { if (file is IArchiveBinaryFile) { var binFile = (IArchiveBinaryFile)file; // export var ms = new MemoryStream(); file.Export(ms); ms.Position = 0; var buf = new byte[ms.Length]; ms.Position = 0; ms.Read(buf, 0, buf.Length); // decrypt... if (binFile.IsEncrypted) { var qq = GTA5Hash.CalculateHash(binFile.Name); var gg = (qq + (uint)binFile.UncompressedSize + (101 - 40)) % 0x65; // TODO: if archive encrypted with AES, use AES key... buf = GTA5Crypto.Decrypt(buf, GTA5Constants.PC_NG_KEYS[gg]); } // decompress... if (binFile.IsCompressed) { var def = new DeflateStream(new MemoryStream(buf), CompressionMode.Decompress); var bufnew = new byte[binFile.UncompressedSize]; def.Read(bufnew, 0, (int)binFile.UncompressedSize); buf = bufnew; } File.WriteAllBytes(fileName, buf); } else { file.Export(fileName); } }
public ResourceFileViewModel(IArchiveFile file) { this.file = file; }
private bool CopyVfsFileInternal(IArchiveFile vfsFile, string filename) { CopyProgressEventArgs args = new CopyProgressEventArgs { CurrentFileSize = vfsFile.Size, CurrentFile = vfsFile.Name, BytesCopied = 0, TotalBytesCopied = 0 }; using (Stream inStream = vfsFile.OpenStream()) { using (Stream outStream = FileSystem.Current.GetFile(filename).OpenStreamWithTimeout(FileMode.Create,FileAccess.Write,FileShare.None)) { long bytesRemaining = vfsFile.Size; byte[] buffer = new byte[BUFFER_SIZE]; while (bytesRemaining > 0) { int bytesRead = (int)(bytesRemaining < BUFFER_SIZE ? bytesRemaining : BUFFER_SIZE); inStream.Read(buffer, 0, bytesRead); outStream.Write(buffer, 0, bytesRead); bytesRemaining -= bytesRead; args.TotalBytesCopied += bytesRead; args.BytesCopied += bytesRead; if (OnCopyProgress != null && (args.BytesCopied % PROGRESS_INCREMENT_SIZE == 0)) { OnCopyProgress(this, args); args.BytesCopied = 0; if (args.Cancel) { Cancel(); return true; } } } } } if (OnCopyProgress != null) { OnCopyProgress(this, args); } return false; }
public static FileType DetermineType(IArchiveFile file) { return file is RageArchiveBinaryFileWrapper7 ? FileType.Binary : FileType.Resource; }
public void CopyVfsFile(IArchiveFile vfsFile, string filename) { if (vfsFile == null) return; CopyVfsFileInternal(vfsFile, filename); }
private bool CopyVfsSubtreeRecursive(IArchiveFile vfsSubtree, string baseDirectory) { if (vfsSubtree.IsFolder) { var directory = FileSystem.Current.GetDirectory(baseDirectory + "/" + vfsSubtree.Name); directory.Create(); foreach (var file in vfsSubtree.Children.Values) { bool cancel = CopyVfsSubtreeRecursive(file, baseDirectory + "/" + vfsSubtree.Name); if (cancel) return true; } } else { string filename = baseDirectory + "/" + vfsSubtree.Name; return CopyVfsFileInternal(vfsSubtree, filename); } return false; }
//when loaded from an install package public FrameworkDependancies(IArchiveFile depsFile) : base(depsFile) { }
public BinaryFileViewModel(IArchiveFile file) { this.file = (IArchiveBinaryFile)file; }
public Archive(ZipFile file, IArchiveFile parent, string name, ZipEntry entry) { Parent = parent; Name = name; IsFolder = false; _entry = entry; _file = file; Children = new Dictionary<string, IArchiveFile>(); }
public Archive(ZipFile file, IArchiveFile parent, string name) { Parent = parent; Name = name; IsFolder = true; _file = file; Children = new Dictionary<string, IArchiveFile>(); }
/// <summary> /// Should we exclude this entry? /// </summary> private bool ExcludeEntry(Project project, IArchiveFile entry) { if (entry.FullPath.EndsWith(".project") && !entry.FullPath.EndsWith($"{project.Name}/.project")) { return true; } return false; }
private void LoadImageFromArchive(IArchiveFile GameFile) { if (GameFile.Parent.Children.ContainsKey(Resources.GameIcon)) { try { IArchiveFile file = GameFile.Parent.Children[Resources.GameIcon]; using (var stream = file.OpenStream()) { _gameIconData =new byte[stream.Length]; stream.Read(_gameIconData,0, (int)stream.Length); } } catch (Exception) { _gameIconData = null; } } }
/// <summary> /// Deletes an existing file inside this directory. /// </summary> public void DeleteFile(IArchiveFile file) { var rf = file as RageArchiveResourceFileWrapper7; if (rf != null) { this.directory.Files.Remove(rf.file); return; } var bf = file as RageArchiveBinaryFileWrapper7; if (bf != null) { this.directory.Files.Remove(bf.file); return; } throw new NotImplementedException(); }
/// <summary> /// Deletes an existing file inside this directory. /// </summary> public void DeleteFile(IArchiveFile file) { throw new NotImplementedException(); }
private static IArchiveFile CreateDirectories(ZipFile file, IArchiveFile root,string[] components,int length) { IArchiveFile parent = root; for (int i = 0; i < length; ++i) { if (!parent.Children.ContainsKey(components[i].ToLowerInvariant())) { var child = new Archive(file,parent, components[i]); parent.Children.Add(child.Name.ToLowerInvariant(), child); parent = child; } else { parent = parent.Children[components[i].ToLowerInvariant()]; } } return parent; }