public static List <string> Number(string directory, List <FileFragmentReference> list, string defaultExtension, bool forceExtension = false) { VirtualFileSystemEntry virtualDirectory = new VirtualFileSystemEntry(directory); //Creates a virtual directory that can then be numbered correctly foreach (var item in list) { int lastIndex = item.filename.Length - 1; if (forceExtension || string.IsNullOrWhiteSpace(Path.GetExtension(item.filename[lastIndex]))) { item.filename[lastIndex] = Path.ChangeExtension(item.filename[lastIndex], defaultExtension); } virtualDirectory.Add(item.filename); } #if (verify) //Verifys that all files still exist //Probably only catches overlapping entries foreach (var item in list) { if (!virdir.Exists(item.filename)) { throw new Exception(Path.Combine(item.filename) + " was not added to the virtual directory"); } } #endif virtualDirectory.NumberChildren(); return(virtualDirectory.Flatten()); }
public static void ExtractHiddenFolder() { var gibberish = new VirtualFileSystemEntry(false, true, "gibberish.txt", "/home/.wh1t3_l1ly/nothing_to_see_here/gibberish.txt", "/home/_ro_h_wh1t3_l1ly/nothing_to_see_here/gibberish.txt", "-rw-------", "root", "root", "file", "Why even look at this gibberish?\n" + "\n" + "54 6b 46 47 53 6c 4a 46 65 31 4e 43 52 55 64 4d 52 30 70 43 66 51 3d 3d\n" + "\n" + "You do you...", new VirtualFileSystemEntry[0] ); var folder = new VirtualFileSystemEntry(false, true, "nothing_to_see_here", "/home/.wh1t3_l1ly/nothing_to_see_here", "/home/_ro_h_wh1t3_l1ly/nothing_to_see_here", "drwx------", "root", "root", "directory", "", new VirtualFileSystemEntry[] { gibberish } ); TerminalHandler.Instance.VirtualFileSystem.AddEntry(folder); TerminalHandler.Instance.VirtualFileSystem.AddEntry(gibberish); TerminalHandler.Instance.DisplayOutput("Archive: wh1t3_l1ly.jpg\n" + "warning[wh1t3_l1ly.jpg]: 27295 extra bytes at beginning or within zipfile\n" + " ls -a(attempting to process anyway)\n" + " inflating: nothing_to_see_here / gibberish.txt"); GameStateHandler.Instance.GameData.ExtractedHiddenFolder = true; GameStateHandler.Instance.SaveGame(); }
private void fixOwnership(VirtualFileSystemEntry entry) { entry.user = TerminalHandler.Instance.TerminalConfig.CurrentUser; entry.group = TerminalHandler.Instance.TerminalConfig.CurrentGroup; if (entry.childs == null) { return; } foreach (var c in entry.childs) { fixOwnership(c); } }
private void AddToBuilderRecursively(CDBuilder isoBuilder, VirtualFileSystemEntry entry, string rootPrefix) { if (entry.EntryType == VirtualFileSystemEntryType.File) { AddFile(isoBuilder, entry.FullName.Remove(0, rootPrefix.Length), (( VirtualFile )entry)); } else { isoBuilder.AddDirectory(entry.FullName.Remove(0, rootPrefix.Length)); foreach (var directoryEntry in ((VirtualDirectory)entry)) { AddToBuilderRecursively(isoBuilder, directoryEntry, rootPrefix); } } }
public VirtualFileSystemEntry Clone() { var output = new VirtualFileSystemEntry( hidden, readable, name, full_path, r_path, flags, user, group, type, content, childs ); return(output); }
public VirtualFileSystemEntry Execute(VirtualDirectory root, string hostOutputPath = null) { var input = root; VirtualFileSystemEntry output = null; while (Stack.Count != 0 ) { var builderInfo = Stack.Pop(); var builder = builderInfo.Create(); output = builder.Build( input, hostOutputPath ); if ( output.EntryType == VirtualFileSystemEntryType.File && Stack.Count != 0 ) { var temp = new VirtualDirectory(); output.MoveTo( temp ); input = temp; } } return output; }