File system directory management

 

Syntax:

str = [get]cwd()

str = [get]jxd()

t/f = cd(path)

t/f = mkdir(path[,mode])

t/f = remove(path)

str = glob(pattern)

 

Synopsis:

The cwd() and jxd() functions return a string with the absolute path of, respectively, the current working directory or the directory containing the main JavaScript program. The current working directory may be changed using the cd() function, which accepts a new path as its only argument. The new path may be specified relative to the current directory (no leading slash) or from the root (by giving a path with a leading slash). The getcwd() and getjxd() functions are identical aliases for cwd() and jxd().

A new directory may be created using the mkdir() function. If the optional second argument is omitted, octal 0770 is assumed. Unlike the mkdir command line program, this function does not create any higher level directories. All directories in the path must already exist, except for the last, which may not yet exist. If a directory is empty (including hidden files) it may be deleted using the remove() function, which actually operates on all types of file system entries.

The glob() function operates similarly to name expansion in command line programs. Its most common use is to obtain a list of all objects in a particular directory. For example, glob('/some/directory/*') will return a string with a comma separated list of the contents of that directory, with tilde expansion and including hidden files (with names beginning in a dot). The entries in this list are terminated with a slash (/) if the item is a directory, while file entries are not. The returned list is already sorted, alphamerically.

 

See also: