diff --git a/CommandFileIO.cs b/CommandFileIO.cs index f0350e8..6e27f30 100644 --- a/CommandFileIO.cs +++ b/CommandFileIO.cs @@ -287,7 +287,7 @@ public override void Evaluate() } } - [CommandAttribute("LIST[VOLUMES,FILES]?")] + [CommandAttribute("LIST[VOLUMES,FILES ON,FILES]?_^?")] public class CommandList : Command { public CommandList(Match regexMatch, ExecutionContext context) : base(regexMatch, context) { } @@ -295,9 +295,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(targetVolume) || String.IsNullOrEmpty(listType) && String.IsNullOrEmpty(targetVolume)) + { - if (listType == "FILES" || String.IsNullOrEmpty(listType)) - { StdOut(""); StdOut("Volume " + GetVolumeBestIdentifier(SelectedVolume)); @@ -316,7 +318,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"); @@ -345,6 +347,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."); } diff --git a/README.md b/README.md index b95e608..3200a0f 100644 --- a/README.md +++ b/README.md @@ -143,12 +143,13 @@ Example: ### LIST -Lists the files on the current 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 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