-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Blaise Ritchie
committed
Nov 22, 2011
1 parent
57dfe15
commit 18c5165
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(""); | ||
} |