Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ls

  • Loading branch information...
commit 18c5165aef8370ce1c222671d8d439836326e036 1 parent 57dfe15
Blaise Ritchie authored
Showing with 37 additions and 0 deletions.
  1. +37 −0 ls.winxed
View
37 ls.winxed
@@ -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("");
+}
Please sign in to comment.
Something went wrong with that request. Please try again.