![]() |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Creating, renaming and removing directories are handled by the
efuns mkdir()
, rename()
and rmdir()
. You need
write permissions in the directory you are doing this, of course.
mkdir()
and rmdir()
return 1 on success and 0 on
failure. rename()
, as already pointed out, works the other
way around and returns 1 on failure, 0 on success. rmdir()
only works if the directory you want to remove is empty, i.e. contains
no other files or directories.
int mkdir(string path); int rename(string oldpath, string newpath); int rmdir(string path); |
For listing the contents of a directory, you can use the efun
get_dir()
. It simply returns an array with the names of all
files in the specified directory, or an empty array on failure.
string *get_dir(string path); e.g. string *dir_contents; int i, sz; dir_contents = get_dir("/d/Domain/fatty"); for (i = 0, sz = sizeof(dir_contents); i < sz; i++) { // See the code for file_info in a previous example file_info(dir_contents[i]); } |