File/directory manipulation

 

Syntax:

t/f = chmod(path,mode)

t/f = chown(path,uid[,gid])

num = copy(path,dest[,mode])

t/f = move(path,dest)

t/f = remove(path)

t/f = utime(path,axs,mod)

 

Synopsis:

The functions on this page are equivalent to the similar command line programs. In fact, they are implemented by JSUS using the same underlying system calls, except for copy(), which uses memory mapped I/O to copy the file at path to a new destination (which may or may not already exist) and then returns the number of UTF-8 bytes copied. The syntax of all the other functions should be self explanatory.

Unlike the "cp" command, the copy() function operates only individual, regular files (and does not recurse into directories). The "path" must already exist (but may have a length of zero bytes). Obviously, the user must also have at least read permission for the file. If the destination file already exists, the user must have write permission for the file. Otherwise a new file is created, owned by the user, and initially with the user's default attributes and current system times. Then, any content in the source file is memory-mapped and written to the destination file. Finally, copy() sets the attributes of the destination file to those of the source (access mode and modification and access times). If the optional mode argument is given, the destination file mode is set to this new value, if possible.

 

See also: