The File System: 4.3 Directories and Paths: Creating and Deleting Directories

Up: GEOS SDK TechDocs | Up | Prev: 4.2 Current Path and Directory Stack | Next: 5 Files
FileCreateDir(), FileDeleteDir()

You can create directories with FileCreateDir() . The routine takes a single argument, namely the address of a character string. If the string is simply a directory name, it will attempt to create that directory at the current location. If the string is a relative path, it will create the directory at the end of the path, if possible. For example, passing the string "Memos\September" will cause it to check if there is a directory called "Memos" at the current location. If there is, it will create the directory "September" inside the directory "Memos". If the string is an absolute path (i.e. there is a backslash before the first directory name), it will behave the same way, but it will start with the root directory. The routine returns zero if it was successful. If it was unsuccessful, it will return one of the following error codes:

ERROR_INVALID_NAME
The name passed was inappropriate for directories on that device.
ERROR_PATH_TOO_LONG
The path string was longer than is permitted by the file system for that device.
ERROR_FILE_EXISTS
A file or directory with the specified name already exists at the specified location.
ERROR_PATH_NOT_FOUND
The path string was in some way invalid; for example, it might have instructed FileCreateDir() to create the directory inside of a directory which does not exist.
ERROR_ACCESS_DENIED
The thread is not able to create directories in the specified location.
ERROR_DISK_STALE
The drive that disk was on has been removed.
ERROR_DISK_UNAVAILABLE
The validation of the disk in that drive was aborted by the user.
ERROR_WRITE_PROTECTED
The volume is write-protected.

Note that the directory name can be any acceptable GEOS file name; that is, it may be up to 32 characters long and can contain any characters other than backslashes, colons, asterisks, or question marks. For further information about GEOS file names, see DOS Files and GEOS Files .

You can delete directories with FileDeleteDir() . This routine takes a single argument, namely the address of a character string. This string can specify a relative or absolute path, as with FileCreateDir() . It attempts to delete the directory specified. (Note that you are not allowed to delete your current directory or a non-empty directory.) If it successfully removes the directory, it returns zero. Otherwise, it returns one of the following members of the FileError type:

ERROR_PATH_NOT_FOUND
The directory specified could not be found or does not exist.
ERROR_IS_CURRENT_DIRECTORY
This directory is some thread's current directory, or else it is on some thread's directory stack. Note that you cannot delete your own working directory.
ERROR_ACCESS_DENIED
The calling thread does not have permission to delete the directory. This is also returned if the directory was on a read-only device.
ERROR_DIRECTORY_NOT_EMPTY
The directory specified is not empty. Delete all the files before you attempt to delete the directory.
ERROR_DISK_STALE
The drive that disk was on has been removed.
ERROR_DISK_UNAVAILABLE
The validation of the disk in that drive was aborted by the user.

Up: GEOS SDK TechDocs | Up | Prev: 4.2 Current Path and Directory Stack | Next: 5 Files