Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions CommandFileIO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,19 @@ 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) { }

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));
Expand All @@ -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");
Expand Down Expand Up @@ -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.");
}
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down