updating oE clear_directory


include filesys.e 
namespace filesys 
public function clear_directory(sequence path, integer recurse = 1) 

clears (deletes) a directory of all files, but retaining sub-directories.

  1. name : a sequence, the name of the directory whose files you want to remove.
  2. recurse : an integer, whether or not to remove files in the directory's sub-directories. If 0 then this function is identical to remove_directory. If 1, then we recursively delete the directory and its contents. Defaults to 1 .

An integer, 0 on failure, otherwise the number of files plus 1 .


This never removes a directory. It only ever removes files. It is used to clear a directory structure of all existing files, leaving the structure intact.

Example 1:
integer cnt = clear_directory("the_old_folder") 
if cnt = 0 then 
	crash("Filesystem problem - could not remove one or more of the files.") 
end if 
printf(1, "Number of files removed: %d\n", cnt - 1) 
See Also:

remove_directory, delete_file

Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu