Add procedure for creating directories
Submitted by saulgoode
Created attachment 270855 Add make-directory procedure
Currently there is no means for Script-fu scripts to create a directory within the filesystem. It would be useful if this functionality were available.
I have added a patch that adds a 'make-directory' procedure to Script-fu. The procedure requires a filename argument, and optionally accepts an additional 'mode' argument. The mode argument is a permissions mask identical to that specified in the Posix 'mkdir' library function. If the mode argument is not supplied then it defaults to all available permissions. In both cases, the mode mask is combined with the process's umask value before applying to the directory.
The procedure return #t upon successful completion of the operation, otherwise it returns #f. Possible reasons for failure are that the directory already exists, the user is not authorized to create it, or that the mode argument was invalid (i.e., not an integer).
The name 'make-directory' was chosen as it appears in the majority of Scheme implementations and is consistent with the naming conventions of other procedures in Script-fu. The name 'make-directory' is currently used by Bigloo, MzScheme, Gambit, MIT, and Racket. There are some other names used for this functionality but they are (in my opinion) less suitable for Script-fu ('mkdir' is used by Guile Scheme, 'ch-mk-dir' is used by Chez Scheme, and 'create-pathname-directory' is used by Chicken Scheme).
Patch 270855, "Add make-directory procedure":
Version: git master