AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
access (String path, int mode) yoix.system
 
Checks whether the local file named by path, which can also begin with the file: prefix, can be accessed according to mode, and returns 0 on success or -1 if there was an error. mode should be zero (or F_OK), which means check for the existence of the file, or an integer produced by a bitwise-ORing of the constants R_OK, W_OK, and X_OK, which are defined in yoix.system.

The ability to test whether a file is really executable or not first appeared in Java 1.6 and in that case access will provide an accurate answer, otherwise the X_OK test is exactly the same as the R_OK test.
 
 Example:   On a UNIX-like system the program,
import yoix.stdio.*;
import yoix.system.*;

String  path = "/etc/passwd";

if (access(path, R_OK) == 0)
    printf("%s is readable\n", path);
else printf("%s is not readable\n", path);

if (access(path, W_OK) == 0)
    printf("%s is writable\n", path);
else printf("%s is not writable\n", path);
usually prints
/etc/passwd is readable
/etc/passwd is not writable
on standard output.
 
 Return:   int
 
 See Also:   directoryListing, fileModified, fileSize, fopen, isDirectoryPath, isFilePath, localPath, mkdir, mkdirs, open, realPath, rename, rmdir, stat, unlink, yoixPath

 

Yoix is a registered trademark of AT&T Inc.