public override void Evaluate() { String targetFile = RegexMatch.Groups[1].Value.Trim(); String operation = RegexMatch.Groups[3].Value.Trim().ToUpper(); String volumeName = RegexMatch.Groups[5].Value.Trim(); File file = null; Volume targetVolume = null; switch (operation) { case "FROM": targetVolume = GetVolume(volumeName); // Will throw if not found file = targetVolume.GetByName(targetFile); if (file == null) { throw new kOSException("File '" + targetFile + "' not found"); } targetVolume.DeleteByName(targetFile); break; default: file = SelectedVolume.GetByName(targetFile); if (file == null) { throw new kOSException("File '" + targetFile + "' not found"); } SelectedVolume.DeleteByName(targetFile); break; } State = ExecutionState.DONE; }
public override void Evaluate() { var fileName = RegexMatch.Groups[1].Value; var file = SelectedVolume.GetByName(fileName); var parameters = new List <Expression.Expression>(); if (RegexMatch.Groups.Count > 1) { var paramstring = RegexMatch.Groups[3].Value; parameters.AddRange( Utils.ProcessParams(paramstring).Select(param => new Expression.Expression(param, this))); } if (file == null) { throw new KOSException("File not found '" + fileName + "'.", this); } var runContext = new ContextRunProgram(this, parameters, fileName); Push(runContext); if (file.Count > 0) { runContext.Run(file); State = ExecutionState.WAIT; } else { State = ExecutionState.DONE; } }
public override void Evaluate() { String fileName = RegexMatch.Groups[1].Value; File file = SelectedVolume.GetByName(fileName); if (file != null) { ContextRunProgram runContext = new ContextRunProgram(this); Push(runContext); if (file.Count > 0) { runContext.Run(file); State = ExecutionState.WAIT; } else { State = ExecutionState.DONE; } } else { throw new kOSException("File not found '" + fileName + "'."); } }
private void Save() { statusAnimstring = SelectedVolume.SaveFile(file) ? "SAVED." : "CAN'T SAVE - DISK FULL."; statusAnimActive = true; statusAnimProg = 0; }
public override void Evaluate() { var targetFile = RegexMatch.Groups[1].Value.Trim(); var volumeName = RegexMatch.Groups[3].Value.Trim(); Persistance.File file; if (volumeName.Trim() != "") { var targetVolume = GetVolume(volumeName); file = targetVolume.GetByName(targetFile); if (file == null) { throw new KOSException("File '" + targetFile + "' not found", this); } targetVolume.DeleteByName(targetFile); } else { file = SelectedVolume.GetByName(targetFile); if (file == null) { throw new KOSException("File '" + targetFile + "' not found", this); } SelectedVolume.DeleteByName(targetFile); } State = ExecutionState.DONE; }
public override void Evaluate() { String targetFile = RegexMatch.Groups[1].Value.Trim(); String volumeName = RegexMatch.Groups[3].Value.Trim(); File file = null; Volume targetVolume = null; if (volumeName.Trim() != "") { targetVolume = GetVolume(volumeName); // Will throw if not found file = targetVolume.GetByName(targetFile); if (file == null) { throw new kOSException("File '" + targetFile + "' not found", this); } targetVolume.DeleteByName(targetFile); } else { file = SelectedVolume.GetByName(targetFile); if (file == null) { throw new kOSException("File '" + targetFile + "' not found", this); } SelectedVolume.DeleteByName(targetFile); } State = ExecutionState.DONE; }
public override void Evaluate() { String listType = RegexMatch.Groups[1].Value.Trim().ToUpper(); if (listType == "FILES" || String.IsNullOrEmpty(listType)) { StdOut(""); StdOut("Volume " + GetVolumeBestIdentifier(SelectedVolume)); StdOut("-------------------------------------"); foreach (FileInfo fileInfo in SelectedVolume.GetFileList()) { StdOut(fileInfo.Name.PadRight(30, ' ') + fileInfo.Size.ToString()); } int freeSpace = SelectedVolume.GetFreeSpace(); StdOut("Free space remaining: " + (freeSpace > -1 ? freeSpace.ToString() : " infinite")); StdOut(""); State = ExecutionState.DONE; return; } else if (listType == "VOLUMES") { StdOut(""); StdOut("ID Name Size"); StdOut("-------------------------------------"); int i = 0; foreach (Volume volume in Volumes) { String id = i.ToString(); if (volume == SelectedVolume) { id = "*" + id; } String line = id.PadLeft(2).PadRight(6, ' '); line += volume.Name.PadRight(24, ' '); String size = volume.CheckRange() ? (volume.Capacity > -1 ? volume.Capacity.ToString() : "Inf") : "Disc"; line += size; StdOut(line); i++; } StdOut(""); State = ExecutionState.DONE; return; } throw new kOSException("List type '" + listType + "' not recognized.", this); }
public override void Evaluate() { var operation = RegexMatch.Groups[1].Value.Trim(); var identifier = RegexMatch.Groups[2].Value.Trim(); var newName = RegexMatch.Groups[3].Value.Trim(); if (operation.ToUpper() == "VOLUME") { var targetVolume = GetVolume(identifier); // Will throw if not found int intTry; if (int.TryParse(newName.Substring(0, 1), out intTry)) { throw new KOSException("Volume name cannot start with numeral", this); } if (targetVolume.Renameable) { targetVolume.Name = newName; } else { throw new KOSException("Volume cannot be renamed", this); } State = ExecutionState.DONE; return; } if (operation.ToUpper() == "FILE" || string.IsNullOrEmpty(operation)) { var f = SelectedVolume.GetByName(identifier); if (f == null) { throw new KOSException("File '" + identifier + "' not found", this); } if (SelectedVolume.GetByName(newName) != null) { throw new KOSException("File '" + newName + "' already exists.", this); } int intTry; if (int.TryParse(newName.Substring(0, 1), out intTry)) { throw new KOSException("Filename cannot start with numeral", this); } f.Filename = newName; State = ExecutionState.DONE; return; } throw new KOSException("Unrecognized renamable object type '" + operation + "'", this); }
public InterpreterEdit(String fileName, ExecutionContext parent) : base(parent) { File = SelectedVolume.GetByName(fileName); if (File == null) { File = new File(fileName); File.Add(""); } CursorX = 0; CursorY = 2; }
public InterpreterEdit(string fileName, IExecutionContext parent) : base(parent) { cursorX = 0; file = SelectedVolume.GetByName(fileName) ?? new File(fileName) { "" }; cursorX = 0; cursorY = 2; RecalcProgramSize(); }
private void Save() { if (SelectedVolume.SaveFile(File)) { StatusAnimString = "SAVED."; } else { StatusAnimString = "CAN'T SAVE - DISK FULL."; } StatusAnimActive = true; StatusAnimProg = 0; }
public void Run(File fileObj) { if (!SelectedVolume.CheckRange()) { StdOut("Selected volume is out of range. Can;t run program."); } else { file = fileObj; State = ExecutionState.WAIT; RunBlock(fileObj); } }
public override void Update(float time) { try { base.Update(time); if (SelectedVolume.CheckRange()) { EvaluateNextCommand(); signalLossWarning = false; } else if (!signalLossWarning) { StdOut("Selected Volume has gone out of range."); signalLossWarning = true; } } catch (KOSException e) { if (ParentContext.FindClosestParentOfType <IContextRunProgram>() != null) { // Error occurs in a child of another running program StdOut("Error in '" + e.Program.Filename + "' on line " + e.LineNumber + ": " + e.Message); State = ExecutionState.DONE; } else { // Error occurs in the top level program StdOut("Error on line " + e.LineNumber + ": " + e.Message); State = ExecutionState.DONE; } } catch (Exception e) { // Non-kos exception! This is a bug, but no reason to kill the OS StdOut("Flagrant error on line " + EXECUTION_LINE); UnityEngine.Debug.Log("Program error"); UnityEngine.Debug.Log(e); State = ExecutionState.DONE; } }
public override void Evaluate() { var targetFile = RegexMatch.Groups[1].Value.Trim(); var volumeName = RegexMatch.Groups[4].Value.Trim(); var operation = RegexMatch.Groups[2].Value.Trim().ToUpper(); var targetVolume = GetVolume(volumeName); // Will throw if not found Persistance.File file; switch (operation) { case "FROM": file = targetVolume.GetByName(targetFile); if (file == null) { throw new KOSException("File '" + targetFile + "' not found", this); } if (!SelectedVolume.SaveFile(new Persistance.File(file))) { throw new KOSException("File copy failed", this); } break; case "TO": file = SelectedVolume.GetByName(targetFile); if (file == null) { throw new KOSException("File '" + targetFile + "' not found", this); } if (!targetVolume.SaveFile(new Persistance.File(file))) { throw new KOSException("File copy failed", this); } break; } State = ExecutionState.DONE; }
public override void Evaluate() { String targetFile = RegexMatch.Groups[1].Value.Trim(); String volumeName = RegexMatch.Groups[4].Value.Trim(); String operation = RegexMatch.Groups[2].Value.Trim().ToUpper(); Volume targetVolume = GetVolume(volumeName); // Will throw if not found File file = null; switch (operation) { case "FROM": file = targetVolume.GetByName(targetFile); if (file == null) { throw new kOSException("File '" + targetFile + "' not found"); } if (!SelectedVolume.SaveFile(new File(file))) { throw new kOSException("File copy failed"); } break; case "TO": file = SelectedVolume.GetByName(targetFile); if (file == null) { throw new kOSException("File '" + targetFile + "' not found"); } targetVolume.SaveFile(new File(file)); break; } State = ExecutionState.DONE; }
public override void Evaluate() { String fileName = RegexMatch.Groups[1].Value; File file = SelectedVolume.GetByName(fileName); var parameters = new List <Expression>(); if (RegexMatch.Groups.Count > 1) { String paramString = RegexMatch.Groups[3].Value; foreach (String param in Utils.ProcessParams(paramString)) { Expression subEx = new Expression(param, this); parameters.Add(subEx); } } if (file != null) { ContextRunProgram runContext = new ContextRunProgram(this, parameters, fileName); Push(runContext); if (file.Count > 0) { runContext.Run(file); State = ExecutionState.WAIT; } else { State = ExecutionState.DONE; } } else { throw new kOSException("File not found '" + fileName + "'.", this); } }