From 9eb2302923b4c135a5155f459db654bc2f2f13b8 Mon Sep 17 00:00:00 2001 From: Eric Oden Date: Sat, 26 Oct 2013 05:07:43 -0500 Subject: [PATCH 1/7] Temp merge to work on other issues. --- CommandFileIO.cs | 53 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/CommandFileIO.cs b/CommandFileIO.cs index f0350e8..c8f1309 100644 --- a/CommandFileIO.cs +++ b/CommandFileIO.cs @@ -190,33 +190,35 @@ public override void Evaluate() } } - [CommandAttribute("LOG * TO &")] + [CommandAttribute("LOG * TO & [ON]?_^?")] public class CommandLog: Command { public CommandLog(Match regexMatch, ExecutionContext context) : base(regexMatch, context) { } public override void Evaluate() { - // Todo: let the user specify a volume "LOG something TO file ON volume" - Volume targetVolume = SelectedVolume; - - // If the archive is out of reach, the signal is lost in space. - if (!targetVolume.CheckRange()) - { - State = ExecutionState.DONE; - return; - } - String targetFile = RegexMatch.Groups[2].Value.Trim(); + String targetVolume = RegexMatch.Groups[4].Value.Trim(); Expression e = new Expression(RegexMatch.Groups[1].Value, ParentContext); if (e.IsNull()) { State = ExecutionState.DONE; } + else if (RegexMatch.Groups[3].Value.Trim() == "ON") + { + Volume trgtVolume = ParentContext.GetVolume(targetVolume); + if (!trgtVolume.CheckRange()) + { + State = ExecutionState.DONE; + return; + } + trgtVolume.AppendToFile(targetFile, e.ToString()); + State = ExecutionState.DONE; + } else { - targetVolume.AppendToFile(targetFile, e.ToString()); + SelectedVolume.AppendToFile(targetFile, e.ToString()); State = ExecutionState.DONE; } } @@ -287,7 +289,7 @@ public override void Evaluate() } } - [CommandAttribute("LIST[VOLUMES,FILES]?")] + [CommandAttribute("LIST[VOLUMES,FILES|FILES ON]?_^?")] public class CommandList : Command { public CommandList(Match regexMatch, ExecutionContext context) : base(regexMatch, context) { } @@ -295,9 +297,11 @@ public CommandList(Match regexMatch, ExecutionContext context) : base(regexMatch public override void Evaluate() { String listType = RegexMatch.Groups[1].Value.Trim().ToUpper(); + String targetVolume = RegexMatch.Groups[2].Value.Trim(); if (listType == "FILES" || String.IsNullOrEmpty(listType)) - { + { + StdOut(""); StdOut("Volume " + GetVolumeBestIdentifier(SelectedVolume)); @@ -345,6 +349,27 @@ public override void Evaluate() State = ExecutionState.DONE; return; } + else if (listType == "FILES ON" && !String.IsNullOrEmpty(targetVolume)) + { + Volume trgtVolume = ParentContext.GetVolume(targetVolume); + StdOut(""); + + StdOut("Volume " + GetVolumeBestIdentifier(trgtVolume)); + StdOut("-------------------------------------"); + + foreach (FileInfo fileInfo in trgtVolume.GetFileList()) + { + StdOut(fileInfo.Name.PadRight(30, ' ') + fileInfo.Size.ToString()); + } + + int freeSpace = trgtVolume.GetFreeSpace(); + StdOut("Free space remaining: " + (freeSpace > -1 ? freeSpace.ToString() : " infinite")); + + StdOut(""); + + State = ExecutionState.DONE; + return; + } throw new kOSException("List type '" + listType + "' not recognized."); } From b6fff24f71a096f9a1a9166706734748a2e125d9 Mon Sep 17 00:00:00 2001 From: Eric Oden Date: Sat, 26 Oct 2013 16:55:47 -0500 Subject: [PATCH 2/7] Final revision. --- CommandFileIO.cs | 20 ++++---------------- README.md | 1 + 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/CommandFileIO.cs b/CommandFileIO.cs index c8f1309..2f8c494 100644 --- a/CommandFileIO.cs +++ b/CommandFileIO.cs @@ -190,7 +190,7 @@ public override void Evaluate() } } - [CommandAttribute("LOG * TO & [ON]?_^?")] + [CommandAttribute("LOG * TO &")] public class CommandLog: Command { public CommandLog(Match regexMatch, ExecutionContext context) : base(regexMatch, context) { } @@ -198,24 +198,12 @@ public CommandLog(Match regexMatch, ExecutionContext context) : base(regexMatch, public override void Evaluate() { String targetFile = RegexMatch.Groups[2].Value.Trim(); - String targetVolume = RegexMatch.Groups[4].Value.Trim(); Expression e = new Expression(RegexMatch.Groups[1].Value, ParentContext); if (e.IsNull()) { State = ExecutionState.DONE; } - else if (RegexMatch.Groups[3].Value.Trim() == "ON") - { - Volume trgtVolume = ParentContext.GetVolume(targetVolume); - if (!trgtVolume.CheckRange()) - { - State = ExecutionState.DONE; - return; - } - trgtVolume.AppendToFile(targetFile, e.ToString()); - State = ExecutionState.DONE; - } else { SelectedVolume.AppendToFile(targetFile, e.ToString()); @@ -289,7 +277,7 @@ public override void Evaluate() } } - [CommandAttribute("LIST[VOLUMES,FILES|FILES ON]?_^?")] + [CommandAttribute("LIST[VOLUMES,FILES ON,FILES]?_^?")] public class CommandList : Command { public CommandList(Match regexMatch, ExecutionContext context) : base(regexMatch, context) { } @@ -299,7 +287,7 @@ public override void Evaluate() String listType = RegexMatch.Groups[1].Value.Trim().ToUpper(); String targetVolume = RegexMatch.Groups[2].Value.Trim(); - if (listType == "FILES" || String.IsNullOrEmpty(listType)) + if (listType == "FILES" && String.IsNullOrEmpty(targetVolume) || String.IsNullOrEmpty(listType) && String.IsNullOrEmpty(targetVolume)) { StdOut(""); @@ -320,7 +308,7 @@ public override void Evaluate() State = ExecutionState.DONE; return; } - else if (listType == "VOLUMES") + else if (listType == "VOLUMES" && String.IsNullOrEmpty(targetVolume)) { StdOut(""); StdOut("ID Name Size"); diff --git a/README.md b/README.md index b95e608..2507098 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,7 @@ Example: LIST. // Lists files on the active volume LIST FILES. // Lists files on the active volume LIST VOLUMES. // Lists all volumes, with their numbers and names + LIST FILES ON 0. // Lists files on volume 0 ### LOCK From b08c1bb4a2d7fc688c2957185389bdb48f772532 Mon Sep 17 00:00:00 2001 From: Eric Oden Date: Sat, 26 Oct 2013 17:00:54 -0500 Subject: [PATCH 3/7] Add back code i accidently removed while tinkering. --- CommandFileIO.cs | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/CommandFileIO.cs b/CommandFileIO.cs index 2f8c494..06631c6 100644 --- a/CommandFileIO.cs +++ b/CommandFileIO.cs @@ -197,18 +197,28 @@ public CommandLog(Match regexMatch, ExecutionContext context) : base(regexMatch, public override void Evaluate() { - String targetFile = RegexMatch.Groups[2].Value.Trim(); - Expression e = new Expression(RegexMatch.Groups[1].Value, ParentContext); + // Todo: let the user specify a volume "LOG something TO file ON volume" + Volume targetVolume = SelectedVolume; - if (e.IsNull()) - { - State = ExecutionState.DONE; - } - else - { - SelectedVolume.AppendToFile(targetFile, e.ToString()); - State = ExecutionState.DONE; - } + // If the archive is out of reach, the signal is lost in space. + if (!targetVolume.CheckRange()) + { + State = ExecutionState.DONE; + return; + } + + String targetFile = RegexMatch.Groups[2].Value.Trim(); + Expression e = new Expression(RegexMatch.Groups[1].Value, ParentContext); + + if (e.IsNull()) + { + State = ExecutionState.DONE; + } + else + { + targetVolume.AppendToFile(targetFile, e.ToString()); + State = ExecutionState.DONE; + } } } From 8ebcc0a8df11c73a5606b47fdb48a0e081b56580 Mon Sep 17 00:00:00 2001 From: Eric Oden Date: Sat, 26 Oct 2013 17:02:40 -0500 Subject: [PATCH 4/7] More formatiing --- CommandFileIO.cs | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/CommandFileIO.cs b/CommandFileIO.cs index 06631c6..ad2efc5 100644 --- a/CommandFileIO.cs +++ b/CommandFileIO.cs @@ -197,29 +197,29 @@ public CommandLog(Match regexMatch, ExecutionContext context) : base(regexMatch, public override void Evaluate() { - // Todo: let the user specify a volume "LOG something TO file ON volume" - Volume targetVolume = SelectedVolume; + // Todo: let the user specify a volume "LOG something TO file ON volume" + Volume targetVolume = SelectedVolume; - // If the archive is out of reach, the signal is lost in space. - if (!targetVolume.CheckRange()) - { - State = ExecutionState.DONE; - return; - } + // If the archive is out of reach, the signal is lost in space. + if (!targetVolume.CheckRange()) + { + State = ExecutionState.DONE; + return; + } - String targetFile = RegexMatch.Groups[2].Value.Trim(); - Expression e = new Expression(RegexMatch.Groups[1].Value, ParentContext); + String targetFile = RegexMatch.Groups[2].Value.Trim(); + Expression e = new Expression(RegexMatch.Groups[1].Value, ParentContext); - if (e.IsNull()) - { - State = ExecutionState.DONE; - } - else - { - targetVolume.AppendToFile(targetFile, e.ToString()); - State = ExecutionState.DONE; - } - } + if (e.IsNull()) + { + State = ExecutionState.DONE; + } + else + { + targetVolume.AppendToFile(targetFile, e.ToString()); + State = ExecutionState.DONE; + } + } } [CommandAttribute("COPY &[TO,FROM][VOLUME]? ^")] From 0a3b9cdf4618e2779304ff7cac87b6f1adb069b1 Mon Sep 17 00:00:00 2001 From: Eric Oden Date: Sat, 26 Oct 2013 17:03:15 -0500 Subject: [PATCH 5/7] Even more. --- CommandFileIO.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CommandFileIO.cs b/CommandFileIO.cs index ad2efc5..6e27f30 100644 --- a/CommandFileIO.cs +++ b/CommandFileIO.cs @@ -219,7 +219,7 @@ public override void Evaluate() targetVolume.AppendToFile(targetFile, e.ToString()); State = ExecutionState.DONE; } - } + } } [CommandAttribute("COPY &[TO,FROM][VOLUME]? ^")] From 3e77afb80e60862f6c38a1e222899fa9834ae90e Mon Sep 17 00:00:00 2001 From: Eric Oden Date: Sat, 26 Oct 2013 17:07:11 -0500 Subject: [PATCH 6/7] Edit readme a bit. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2507098..2f9c6b8 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ Example: ### LIST -Lists the files on the current volume, or lists the currently available volumes. Lists files by default. +Lists the files on the current or remote volume, or lists the currently available volumes. Lists files by default. Example: LIST. // Lists files on the active volume From f6a22a29f3e03f5479a17d242fae30c067238ba1 Mon Sep 17 00:00:00 2001 From: Eric Oden Date: Sat, 26 Oct 2013 17:10:44 -0500 Subject: [PATCH 7/7] More readme edits. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f9c6b8..3200a0f 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ Example: ### LIST -Lists the files on the current or remote volume, or lists the currently available volumes. Lists files by default. +Lists the files on volumes, or lists the currently available volumes. Lists files by default. Example: LIST. // Lists files on the active volume