/// <summary> /// Finds and returns the root dir (the dir with parent id -1). /// If no root dir is found, null is returned. /// Only call this if the file system data was loaded. /// </summary> public static HashDir GetRootDir() { var data = DataHolder.DeviceData.CurrentDevice.FileSystem; if (data.RootDir != null) { return(data.RootDir); } foreach (var dir in data.AllDirectories) { if (dir.Value.ParentDirId == -1) { return(dir.Value); } } DebugUtil.Error("Did not found any root folder!"); return(null); }
public static void RemoveTextEntries(int quantity, TerminalEntryRemoveType removeType) { var allEntries = DataHolder.TerminalData.AllEntries; quantity = Math.Min(quantity, allEntries.Count); if (quantity == 0) { return; } switch (removeType) { case TerminalEntryRemoveType.OlderEntries: for (int i = 0; i < quantity; i++) { var item = SList.Dequeue(allEntries); GameObject.Destroy(item.SceneObject); } break; case TerminalEntryRemoveType.NewerEntries: for (int i = 0; i < quantity; i++) { var item = SList.Pop(allEntries); GameObject.Destroy(item.SceneObject); } break; default: DebugUtil.Error(string.Format("TERMINAL ENTRY REMOVE TYPE '{0}' NOT IMPLEMENTED!", removeType)); break; } UpdateTableAndScroll(); }
public static void Execute(ProgramExecutionOptions options) { if (ProgramUtil.ShowHelpIfNeeded(options)) { return; } if (CommandLineUtil.ValidateArguments(options.ParsedArguments, Validations)) { Pair <string, string> pathArg; // no need to validate this because the argument is required CommandLineUtil.TryGetArgumentByName(options.ParsedArguments, PathArgName, out pathArg); var path = pathArg.Value; bool openOnTerminal = CommandLineUtil.ArgumentExists(options.ParsedArguments, TerminalArgName); HashFile file; HashDir dir; if (FileSystem.FileExistsAndIsAvailable(path, out file)) { var permission = FileSystem.GetAccessPermission(file); if (permission < AccessPermission.Editable) { var msg = "You don't have permission to open this file."; msg = TextUtil.Error(msg); TerminalUtil.ShowText(msg); } else { switch (file.FileType) { case HashFileType.Text: var textFile = file.Content as TextFile; OpenTextFile(file, textFile, openOnTerminal); break; case HashFileType.Image: var imageFile = file.Content as ImageFile; OpenImageFile(file, imageFile, openOnTerminal); break; default: DebugUtil.Error(string.Format("The open program can't open file type: {0}", file.FileType)); break; } } } else { string msg; if (FileSystem.DirExists(path, out dir)) { msg = "The path '{0}' points to a directory. Please use 'cd {0}' to navigate to that directory."; } else { msg = "The path '{0}' points to nowhere. Please supply a valida path."; } msg = string.Format(msg, path); msg = TextUtil.Error(msg); TerminalUtil.ShowText(msg); } } else { string msg = "Please supply a file path."; msg = TextUtil.Error(msg); TerminalUtil.ShowText(msg); } }