20 lines
544 B
TypeScript
20 lines
544 B
TypeScript
function ls(curdir:any):string {
|
|
var buf = "";
|
|
buf += "Files in the current directory:\n";
|
|
//list only first level files
|
|
for (var key in curdir) {
|
|
//buf += key + "\n";
|
|
//also print if it is a directory or file
|
|
if (typeof curdir[key] == "string") {
|
|
buf += key + " (file)\n";
|
|
}
|
|
else if (typeof curdir[key] == "object") {
|
|
buf += key + " (directory)\n";
|
|
}
|
|
else {
|
|
buf += key + " (unknown)\n";
|
|
}
|
|
}
|
|
return buf;
|
|
}
|
|
export { ls }; |