Beispiel #1
0
        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;
        }
Beispiel #2
0
        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 + "'.");
            }
        }
Beispiel #3
0
        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;
            }
        }
Beispiel #4
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;
        }
Beispiel #5
0
        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;
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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;
        }
Beispiel #8
0
        public InterpreterEdit(string fileName, IExecutionContext parent) : base(parent)
        {
            cursorX = 0;
            file    = SelectedVolume.GetByName(fileName) ?? new File(fileName)
            {
                ""
            };

            cursorX = 0;
            cursorY = 2;

            RecalcProgramSize();
        }
Beispiel #9
0
        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;
        }
Beispiel #10
0
        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;
        }
Beispiel #11
0
        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);
            }
        }