Skip to content

Commit

Permalink
ls
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaise Ritchie committed Nov 22, 2011
1 parent 57dfe15 commit 18c5165
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions ls.winxed
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function show_help(var args) {
print("Usage: ");
print(args[0]);
say(" [directory]");
exit(0);
}

function main[main](var args) {
var rosella = load_packfile("rosella/core.pbc");
var(Rosella.initialize_rosella)("filesystem");
var dirname = ".";
for(var i = 1; i < args; i++) {
var arg = args[i];
if(arg == "-h" || arg == "--help")
show_help(args);
else
dirname = arg;
}
var dir = new Rosella.FileSystem.Directory(dirname);
if(!(dir.exists())) {
print("ls: cannot access ");
print(dirname);
say(": No such file or directory");
exit(-1);
}
var files = dir.get_files();
for(var file in files) {
print(file.short_name());
print(" ");
}
var dirs = dir.get_subdirectories();
for(var curdir in dirs) {
print(curdir.short_name());
print(" ");
}
say("");
}

0 comments on commit 18c5165

Please sign in to comment.