This shows you the differences between two versions of the page.
— |
fexist [2008/05/28 19:46] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | # $EPIC: fexist.txt,v 1.4 2008/05/28 19:46:15 jnelson Exp $ | ||
+ | ======Synopsis:====== | ||
+ | $__fexist__(%%<file>%%) \\ | ||
+ | $__fexist__(%%"" <file>%%) | ||
+ | |||
+ | ======Technical:====== | ||
+ | * The %%<file>%% argument is a [[what is a word|dword]] which is different from most function arguments. | ||
+ | * In the first case, %%<file>%% is a single extended word (you may surround it with double quotes if it contains spaces). Any further arguments are ignored. | ||
+ | * In the second case, the first argument is an empty string, and the rest of the arguments are taken as a filename literally. Do not backslash or double quote anything in%% <file>%%. | ||
+ | * Tilde-expansion is supported in both forms, both "~/file" for files in your home directory and "~user/file" for files in someone else's home directory. | ||
+ | * If %%<file>%% is not a symbolic link, it exists, and you have read access to it, the return value is 1. | ||
+ | * If %%<file>%% is a symbolic link and the file it points to exists, and you have read access to it, the return value is 1. | ||
+ | * In the other cases (the file doesn't exist, or you can't read it), the return value is -1. | ||
+ | |||
+ | ======Practical:====== | ||
+ | This function is used when you want to see if a particular file exists. | ||
+ | This could be useful to make sure a file is present before trying to | ||
+ | load it. This function does not return 0! | ||
+ | |||
+ | ======Returns:====== | ||
+ | <file> | ||
+ | -1 file does not exist or is not readable by you. | ||
+ | 1 file exists and you can read it. | ||
+ | </file> | ||
+ | |||
+ | ======Examples:====== | ||
+ | <file> | ||
+ | $fexist(/etc/passwd) probably will return 1 | ||
+ | $fexist(~/.ircrc) probably will return 1 too | ||
+ | $fexist(fake_file) returns -1 | ||
+ | </file> | ||
+ | |||
+ | ======History:====== | ||
+ | This function first appeared in EPIC3pre7. | ||