# remove_directory

Definition: | bool res = remove_directory(string dir_name, bool force=false)
Description: | Remove a directory. dir_name: the directory to remove. force: if true (1) this will also remove files and sub-directories in the directory. The default is false (0), which means that it will only remove the directory if it is already empty. Returns: false (0) on failure, true (1) on success.
pwa/p2js: | Not supported.
Comments: | Unlike some other routines here, any path separators should be appropriate for the operating system, namely backslash ('\\') on Windows and forwardslash ('/') on Linux. If in doubt (not already a result from the top half of the table) pass src/dest through get_proper_path() and/or get_proper_dir() before passing them to this routine. A trailing slash is optional, it makes no difference whether one is present or not. The use of a named parameter when setting the force flag is recommended, to make the intent clear and the code easier to read.
Example: |
    if not remove_directory("the_old_folder") then
        crash("Filesystem problem - could not remove the old folder")
    end if
Implementation: | See builtins\pfile.e (an autoinclude) for details of the actual implementation.
See Also: | create_directory, chdir, clear_directory