
Function: directory_exists
Check if a directory in the file-system exists or not. Can be used to conditionaly create directories before putting files in them, to example.
Prototype:
bool z = directory_exists ( string path );
Parameters:
Parameter name | Type | Description |
---|---|---|
path | string | path to directory, without a trailing slash (/) |
Return value: Type Bool : True if the directory exists, otherwise false.
Example:
string dir = "/users/ole/Desktop/MyLoggFiles", res;
if ( ! direcotry_exists ( dir)) then
res = create_directory ( dir );
end if
// Put some log-file in it.
string loggfile = dir + "/loggfile.txt"
int x = open ( loggfile, "wa" );
write ( x, format ("%s Some logg text...", string(now(), "yyyy-mm-dd" )));
close ( x );
See also:
- Create_Direcotory
- Delete_Directory
- File_Exists