| directoryListing |
(String path) |
yoix.system |
| |
returns an array of strings corresponding to the contents of the
directory specified by
path.
The familiar "." and ".." references to the current and parent directories,
respectively, are not included in the returned names.
| |
| Example: |
The following example uses
directoryListing
to get a listing of the files in the supplied directory and prints them
sorted by increasing size.
import yoix.stdio.*;
import yoix.system.*;
if(argc != 2) {
fprintf(stderr, "usage: %s directory_path\n", argv[0]);
exit(1);
}
Array files = directoryListing(argv[1]);
Array listing[files@length];
String path;
int i;
compare(s, t) {
int r = (t.filesize - s.filesize);
return(r==0 ? yoix.string.compareTo(t.filename,s.filename) : r);
}
for(i=0; i<files@length; i++) {
path = yoixPath(argv[1] + "/" + files[i]);
listing[i] = new Dictionary {
int filesize = fileSize(path);
String filename = path;
};
}
yoix.util.qsort(listing, compare);
for(i=0; i<files@length; i++) {
fprintf(stdout,
"%10d %s\n", listing[i].filesize, listing[i].filename);
}
exit(0);
| | |
| Return: |
Array
| | |
| See Also: |
access,
fileModified,
fileSize,
fopen,
isDirectoryPath,
isFilePath,
localPath,
mkdir,
mkdirs,
open,
realPath,
rename,
rmdir,
stat,
unlink,
yoixPath
|
|
Yoix is a registered trademark of AT&T Inc.
|