Qore Programming Language Reference Manual  0.8.12.11
 All Classes Namespaces Functions Variables Groups Pages
Filesystem Functions

Functions

bool Qore::absolute_path (string path)
 returns True if the argument is an absolute path on the current platform, False if not More...
 
bool Qore::absolute_path_unix (string path)
 returns True if the argument is a UNIX absolute path, False if not More...
 
bool Qore::absolute_path_windows (string path)
 returns True if the argument is a Windows absolute path, False if not More...
 
int Qore::chdir (string path)
 Changes the current working directory for the current process. More...
 
int Qore::chmod (string path, softint mode)
 Changes the mode of a file or directory. More...
 
int Qore::chown (string path, softint owner=-1, softint group=-1)
 Changes the user and group owners of a file, if the current user has permission to do so (normally only the superuser can change the user owner), follows symbolic links. More...
 
*string Qore::getcwd ()
 Returns a string giving the current working directory or NOTHING if the current working directory could not be read. More...
 
string Qore::getcwd2 ()
 Returns a string giving the current working directory; throws an exception if the current directory cannot be read. More...
 
*list Qore::glob (string glob_str)
 Returns a list of files matching the string argument or NOTHING if the call to glob() fails. More...
 
nothing Qore::glob ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
*hash Qore::hlstat (string path)
 Returns a hash of file status values for the path argument and does not follow symbolic links; if any errors occur, NOTHING is returned and errno() can be used to retrieve the error number. More...
 
nothing Qore::hlstat ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
*hash Qore::hstat (string path)
 Returns a hash of file status values for the path argument, following any symbolic links; if any errors occur, NOTHING is returned and errno() can be used to retrieve the error number. More...
 
nothing Qore::hstat ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
bool Qore::is_bdev (string path)
 Returns True if the string passed identifies a block device on the filesystem, False if not. More...
 
bool Qore::is_cdev (string path)
 Returns True if the string passed identifies a character device on the filesystem, False if not. More...
 
bool Qore::is_dev (string path)
 Returns True if the string passed identifies a device (either block or character) on the filesystem, False if not. More...
 
bool Qore::is_dir (string path)
 Returns True if the string passed identifies a directory on the filesystem, False if not. More...
 
bool Qore::is_executable (string path)
 Returns True if the string passed identifies an executable on the filesystem, False if not. More...
 
bool Qore::is_file (string path)
 Returns True if the string passed identifies a regular file on the filesystem, False if not. More...
 
bool Qore::is_link (string path)
 Returns True if the string passed identifies a symbolic link on the filesystem, False if not. More...
 
bool Qore::is_pipe (string path)
 Returns True if the string passed identifies a pipe (FIFO) on the filesystem, False if not. More...
 
bool Qore::is_readable (string path)
 Returns True if the string passed identifies a file or a directory readable by the current user, False if not. More...
 
bool Qore::is_socket (string path)
 Returns True if the string passed identifies a socket on the filesystem, False if not. More...
 
bool Qore::is_writable (string path)
 Returns True if the string passed identifies a file or a directory writable by the current user, False if not. More...
 
bool Qore::is_writeable (string path)
 Returns True if the string passed identifies a file or a directory writable by the current user (backwards-compatible misspelling of is_writable()) More...
 
int Qore::lchown (string path, softint uid=-1, softint gid=-1)
 Changes the user and group owners of a file, if the current user has permission to do so (normally only the superuser can change the user owner), does not follow symbolic links but rather operates on the symbolic link itself. More...
 
*list Qore::lstat (string path)
 Returns a list of file status values for the path argument and does not follow symbolic links; if any errors occur, NOTHING is returned and errno() can be used to retrieve the error number. More...
 
nothing Qore::lstat ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
int Qore::mkdir (string path, softint mode=0777)
 Creates a directory, optionally specifying the mode. More...
 
int Qore::mkfifo (string path, softint mode=0600)
 Creates a named pipe file with an optional file mode. More...
 
string Qore::readlink (string path)
 Returns the target of a symbolic link; throws an exception if an error occurs (ex: file does not exist or is not a symbolic link) More...
 
string Qore::realpath (string path)
 Returns the canonicalized absolute pathname from the given path. More...
 
nothing Qore::rename (string old_path, string new_path)
 Renames (or moves) files or directories. Note that for this call to function properly, the Qore process must have sufficient permissions and access to the given filesystem objects or paths to execute the rename operation. More...
 
int Qore::rmdir (string path)
 Removes a directory. More...
 
*list Qore::stat (string path)
 Returns a list of file status values for the path argument, following any symbolic links; if any errors occur, NOTHING is returned and errno() can be used to retrieve the error number. More...
 
nothing Qore::stat ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
*hash Qore::statvfs (string path)
 Returns a hash of filesystem status values for the file or directory path passed. More...
 
nothing Qore::symlink (string old_path, string new_path)
 Creates a symbolic link to a directory path. Note that for this call to function properly, the Qore process must have sufficient permissions and access to the given filesystem path to create the symbolic link. More...
 
int Qore::umask (softint mask)
 Sets the file creation mode mask for the process and returns the previous value of the file creation mode mask. More...
 
nothing Qore::umask ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
int Qore::unlink (string path)
 Deletes a file and returns 0 for success, -1 for error (in which case errno() can be used to get the error) More...
 
nothing Qore::unlink ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 

Detailed Description

The following functions return information about or are related to the filesystem.

All of the functions in this section (except umask()) are flagged with Qore::PO_NO_FILESYSTEM

See Also
the File class for a class enabling files to be created, read or written, and the Dir class allowing directories to be manipulated

Filesystem Status Hash

Key Description
namemax The maximum length in mytes of file names on the filesystem
fsid The filesystem ID; may not be set or meaningful on all filesystems/systems: see system documentation for statvfs()
frsize The size in bytes of the minimum allocation unit on the filesystem
bsize The filesystem's block size
flag Flags describing mount options for the filesystem
files The total number of inodes on the filesystem
favail The number of free inodes available to unpriviledged users
ffree The total number of free indes available to priviledged users
blocks The total number of blocks on the filesystem (capacity in bytes = bsize * blocks)
bavail The number of free blocks available to unpriviledged users (bytes = bsize * bavail)
bfree The total number of free indes available to priviledged users (bytes = bsize * bfree)

Stat List

Element Data Type Description
0 int device inode number the file is on
1 int inode of the file
2 int inode protection mode
3 int number of hard links to this file
4 int user ID of the owner
5 int group ID of the owner
6 int device type number
7 int file size in bytes
8 date last access time of the file
9 date last modified time of the file
10 date last change time of the file's inode
11 int block size; may be zero if the platform's internal stat() (2) function does not provide this info
12 int blocks allocated for the file; may be zero if the platform's internal stat() (2) function does not provide this info

Stat Hash

Key Data Type Description
dev int device inode number the file is on
inode int inode of the file
mode int inode protection mode
nlink int number of hard links to this file
uid int user ID of the owner
gid int group ID of the owner
rdev int device type number
size int file size in bytes
atime date last access time of the file
mtime date last modified time of the file
ctime date last change time of the file's inode
blksize int block size; may be zero if the platform's internal stat() (2) function does not provide this info
blocks int blocks allocated for the file; may be zero if the platform's internal stat() (2) function does not provide this info
type string a string giving the file type; one of:
- "BLOCK-DEVICE"
- "DIRECTORY"
- "CHARACTER-DEVICE"
- "FIFO"
- "SYMBOLIC-LINK"
- "SOCKET"
- "REGULAR"
- "UNKNOWN"
perm string a string giving UNIX-style permissions for the file (ex: "-rwxr-xr-x")

Function Documentation

bool Qore::absolute_path ( string  path)

returns True if the argument is an absolute path on the current platform, False if not

Code Flags:
CONSTANT
Example:
1 bool abs = absolute_path(path);
Parameters
paththe path to check
Returns
True if the argument is an absolute path, False if not
See Also
Since
Qore 0.8.12 this function is a native function in Qore; moved from the Util module
bool Qore::absolute_path_unix ( string  path)

returns True if the argument is a UNIX absolute path, False if not

Code Flags:
CONSTANT
Example:
1 bool abs = absolute_path_unix(path);
Parameters
paththe path to check
Returns
True if the argument is a UNIX absolute path, False if not
See Also
Since
Qore 0.8.12 this function is a native function in Qore; moved from the Util module
bool Qore::absolute_path_windows ( string  path)

returns True if the argument is a Windows absolute path, False if not

Code Flags:
CONSTANT
Example:
1 bool abs = absolute_path_windows(path);
Parameters
paththe path to check
Returns
True if the argument is a Windows absolute path, False if not
See Also
Since
Qore 0.8.12 this function is a native function in Qore; moved from the Util module
int Qore::chdir ( string  path)

Changes the current working directory for the current process.

Restrictions:
Qore::PO_NO_PROCESS_CONTROL, Qore::PO_NO_FILESYSTEM
Parameters
paththe new working directory for the current process
Returns
0 if no error occurred; -1 if an error occurred, in which case errno() and/or strerror() can be used to retrieve the error
Example:
1 if (chdir(dir))
2  printf("chdir %s: %s\n", dir, strerror());
Since
Qore 0.8.4 this function is tagged with Qore::PO_NO_PROCESS_CONTROL
int Qore::chmod ( string  path,
softint  mode 
)

Changes the mode of a file or directory.

Restrictions:
Qore::PO_NO_FILESYSTEM
Parameters
paththe path to the file or directory to change
modethe new mode for the file or directory
Returns
0 if no error occurred; -1 if an error occurred, in which case errno() and/or strerror() can be used to retrieve the error
Example:
1 if (chmod("/bin/login", 0755))
2  printf("rmdir /tmp/newdir: %s\n", strerror());
int Qore::chown ( string  path,
softint  owner = -1,
softint  group = -1 
)

Changes the user and group owners of a file, if the current user has permission to do so (normally only the superuser can change the user owner), follows symbolic links.

Platform Availability:
Qore::Option::HAVE_UNIX_FILEMGT
Restrictions:
Qore::PO_NO_FILESYSTEM
Parameters
pathpath to the file or directory to change
ownerthe uid of the new user owner; -1 means do not change user owner
groupthe gid of the new group owner; -1 means do not change group owner
Returns
0 if no error occurred; -1 if an error occurred, in which case errno() and/or strerror() can be used to retrieve the error
Example:
1 if (chown("/bin/login", 0, 0))
2  printf("chown /bin/login: %s\n", strerror());
See Also
lchown() for a version of this function that does not follow symbolic links
*string Qore::getcwd ( )

Returns a string giving the current working directory or NOTHING if the current working directory could not be read.

Returns
a string giving the current working directory or NOTHING if the current working directory could not be read
Restrictions:
Qore::PO_NO_FILESYSTEM, Qore::PO_NO_EXTERNAL_INFO
Code Flags:
CONSTANT
Example:
1 *string cwd = getcwd();
See Also
getcwd2() for a similar function that throws an exception if an error occurs instead
string Qore::getcwd2 ( )

Returns a string giving the current working directory; throws an exception if the current directory cannot be read.

Restrictions:
Qore::PO_NO_FILESYSTEM, Qore::PO_NO_EXTERNAL_INFO
Code Flags:
RET_VALUE_ONLY
Example:
1 string cwd = getcwd2();
See Also
getcwd() for a similar function that returns NOTHING instead of throwing an exception if an error occurs
*list Qore::glob ( string  glob_str)

Returns a list of files matching the string argument or NOTHING if the call to glob() fails.

Restrictions:
Qore::PO_NO_FILESYSTEM
Parameters
glob_strthe glob string, containing an optional path (in which case the entire path must be readable) and a glob filename pattern
Returns
a list of files matching the string argument or NOTHING if the call to glob() fails, in which case errno() can be used to get the error
Example:
1 *list gl = glob("*.txt");
2 if (!exists gl)
3  printf("failed to glob *.txt: %s\n", strerror());
nothing Qore::glob ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
RUNTIME_NOOP
*hash Qore::hlstat ( string  path)

Returns a hash of file status values for the path argument and does not follow symbolic links; if any errors occur, NOTHING is returned and errno() can be used to retrieve the error number.

Restrictions:
Qore::PO_NO_FILESYSTEM
Parameters
paththe path to retrieve information for
Returns
a hash of file status values for the path argument and does not follow symbolic links; if any errors occur, NOTHING is returned and errno() can be used to retrieve the error number
Example:
1 *hash h = hlstat("/tmp/file.txt");
2 if (!exists h)
3  printf("could not hlstat /tmp/file.txt: %s\n", strerror());
See Also
hstat() for a version of this function that follows symbolic links

lstat() for a version of this function that returns a traditional list instead of a user-friendly hash

File::hlstat() for a static method in the File class that throws an exception instead of returning NOTHING when errors occur
nothing Qore::hlstat ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
RUNTIME_NOOP
*hash Qore::hstat ( string  path)

Returns a hash of file status values for the path argument, following any symbolic links; if any errors occur, NOTHING is returned and errno() can be used to retrieve the error number.

Restrictions:
Qore::PO_NO_FILESYSTEM
Parameters
paththe path to retrieve information for
Returns
a hash of file status values for the path argument, following any symbolic links; if any errors occur, NOTHING is returned and errno() can be used to retrieve the error number
Example:
1 *hash h = hstat("/tmp/file.txt");
2 if (!exists h)
3  printf("could not hstat /tmp/file.txt: %s\n", strerror());
See Also
hlstat() for a version of this function that does not follow symbolic links

stat() for a version of this function that returns a traditional list instead of a user-friendly hash

File::hstat() for a static method in the File class that throws an exception instead of returning NOTHING when errors occur
nothing Qore::hstat ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
RUNTIME_NOOP
bool Qore::is_bdev ( string  path)

Returns True if the string passed identifies a block device on the filesystem, False if not.

Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
CONSTANT
Parameters
paththe path to check
Returns
True if the string passed identifies a block device on the filesystem, False if not
Example:
1 bool b = is_bdev("/tmp/sda1");
bool Qore::is_cdev ( string  path)

Returns True if the string passed identifies a character device on the filesystem, False if not.

Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
CONSTANT
Parameters
paththe path to check
Returns
True if the string passed identifies a character device on the filesystem, False if not
Example:
1 bool b = is_cdev("/tmp/tty");
bool Qore::is_dev ( string  path)

Returns True if the string passed identifies a device (either block or character) on the filesystem, False if not.

Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
CONSTANT
Parameters
paththe path to check
Returns
True if the string passed identifies a device (either block or character) on the filesystem, False if not
Example:
1 bool b = is_dev("/tmp/scanner");
bool Qore::is_dir ( string  path)

Returns True if the string passed identifies a directory on the filesystem, False if not.

Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
CONSTANT
Parameters
paththe path to check
Returns
True if the string passed identifies a directory on the filesystem, False if not
Example:
1 bool b = is_dir("/tmp/mydir");
bool Qore::is_executable ( string  path)

Returns True if the string passed identifies an executable on the filesystem, False if not.

Platform Availability
Qore::Option::HAVE_IS_EXECUTABLE
Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
CONSTANT
Parameters
paththe path to check
Returns
True if the string passed identifies an executable on the filesystem, False if not
Example:
1 bool b = is_executable("/bin/login");
bool Qore::is_file ( string  path)

Returns True if the string passed identifies a regular file on the filesystem, False if not.

Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
CONSTANT
Parameters
paththe path to check
Returns
True if the string passed identifies a regular file on the filesystem, False if not
Example:
1 bool b = is_file("/etc/hosts");
bool Qore::is_link ( string  path)

Returns True if the string passed identifies a symbolic link on the filesystem, False if not.

Platform Availability
Qore::Option::HAVE_UNIX_FILEMGT
Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
CONSTANT
Parameters
paththe path to check
Returns
True if the string passed identifies a symbolic link on the filesystem, False if not
Example:
1 bool b = is_link("/etc/hosts");
bool Qore::is_pipe ( string  path)

Returns True if the string passed identifies a pipe (FIFO) on the filesystem, False if not.

Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
CONSTANT
Parameters
paththe path to check
Returns
True if the string passed identifies a pipe (FIFO) on the filesystem, False if not
Example:
1 bool b = is_pipe("/tmp/mypipe");
bool Qore::is_readable ( string  path)

Returns True if the string passed identifies a file or a directory readable by the current user, False if not.

Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
CONSTANT
Parameters
paththe path to check
Returns
True if the string passed identifies a file or a directory readable by the current user, False if not
Example:
1 bool b = is_readable("/etc/hosts");
bool Qore::is_socket ( string  path)

Returns True if the string passed identifies a socket on the filesystem, False if not.

Platform Availability
Qore::Option::HAVE_UNIX_FILEMGT
Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
CONSTANT
Parameters
paththe path to check
Returns
True if the string passed identifies a socket on the filesystem, False if not
Example:
1 bool b = is_socket("/tmp/X0");
bool Qore::is_writable ( string  path)

Returns True if the string passed identifies a file or a directory writable by the current user, False if not.

Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
CONSTANT
Parameters
paththe path to check
Returns
True if the string passed identifies a file or a directory writable by the current user, False if not
Example:
1 bool b = is_writable("/etc/hosts");
Since
Qore 0.8.12 this function works properly on Windows
bool Qore::is_writeable ( string  path)

Returns True if the string passed identifies a file or a directory writable by the current user (backwards-compatible misspelling of is_writable())

Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
CONSTANT
Parameters
paththe path to check
Returns
True if the string passed identifies a file or a directory writable by the current user, False if not
Example:
1 bool b = is_writeable("/etc/hosts");
Since
Qore 0.8.12 this function works properly on Windows
int Qore::lchown ( string  path,
softint  uid = -1,
softint  gid = -1 
)

Changes the user and group owners of a file, if the current user has permission to do so (normally only the superuser can change the user owner), does not follow symbolic links but rather operates on the symbolic link itself.

Platform Availability:
Qore::Option::HAVE_UNIX_FILEMGT
Restrictions:
Qore::PO_NO_FILESYSTEM
Parameters
pathpath to the file or directory to change
uidthe uid of the new user owner; -1 means do not change user owner
gidthe gid of the new group owner; -1 means do not change group owner
Returns
0 if no error occurred; -1 if an error occurred, in which case errno() and/or strerror() can be used to retrieve the error
Example:
1 if (lchown("/tmp/socket", 0, 0))
2  printf("lchown /tmp/socket: %s\n", strerror());
See Also
chown() for a version of this function that follows symbolic links (ie operates on the target instead of on the link itself)
*list Qore::lstat ( string  path)

Returns a list of file status values for the path argument and does not follow symbolic links; if any errors occur, NOTHING is returned and errno() can be used to retrieve the error number.

Restrictions:
Qore::PO_NO_FILESYSTEM
Parameters
paththe path to retrieve information for
Returns
a list of file status values for the path argument and does not follow symbolic links; if any errors occur, NOTHING is returned and errno() can be used to retrieve the error number
Example:
1 *list l = lstat("/tmp/file.txt");
2 if (!exists l)
3  printf("could not lstat /tmp/file.txt: %s\n", strerror());
Note
on platforms without symbolic links (such as with native Windows ports, for example), this function is identical to stat()
See Also
stat() for a version of this function that follows symbolic links

hlstat() for a version of this function that returns a user-friendly hash instead of a list

File::lstat() for a static method in the File class that throws an exception instead of returning NOTHING when errors occur
nothing Qore::lstat ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
RUNTIME_NOOP
int Qore::mkdir ( string  path,
softint  mode = 0777 
)

Creates a directory, optionally specifying the mode.

Restrictions:
Qore::PO_NO_FILESYSTEM
Parameters
paththe path to the directory to create
modethe file mode of the new directory (which will be AND'ed with the umask)
Returns
0 if no error occurred; -1 if an error occurred, in which case errno() and/or strerror() can be used to retrieve the error
Example:
1 if (mkdir("/tmp/newdir", 0755))
2  printf("mkdir /tmp/newdir: %s\n", strerror());
See Also
umask()
int Qore::mkfifo ( string  path,
softint  mode = 0600 
)

Creates a named pipe file with an optional file mode.

Platform Availability:
Qore::Option::HAVE_UNIX_FILEMGT
Restrictions:
Qore::PO_NO_FILESYSTEM
Parameters
paththe path to the new named pipe
modethe file mode for the new named pipe
Returns
0 if no error occurred; -1 if an error occurred, in which case errno() and/or strerror() can be used to retrieve the error
Example:
1 if (mkfifo("/tmp/pipe"))
2  printf("mkfifo /tmp/pipe: %s\n", strerror());
string Qore::readlink ( string  path)

Returns the target of a symbolic link; throws an exception if an error occurs (ex: file does not exist or is not a symbolic link)

Platform Availability:
Qore::Option::HAVE_UNIX_FILEMGT
Restrictions:
Qore::PO_NO_FILESYSTEM
Parameters
paththe path to the symbolic link
Returns
the target of the link; throws an exception if the given path is not a symbolic link (or if another error occurs)
Example:
1 string str = readlink("/tmp/symbolic_link");
Exceptions
READLINK-ERRORInvalid arguments or a system error occured (ex: file does not exist or is not a symbolic link)
string Qore::realpath ( string  path)

Returns the canonicalized absolute pathname from the given path.

Restrictions:
Qore::PO_NO_FILESYSTEM
Example:
1 string realpath = realpath(path);
Parameters
paththe path to process
Returns
the corresponding absolute path with all relative references removed and all symbolic links resolved (if applicable for the current platform)
Exceptions
REALPATH-ERRORif an error occurs calculating the return value then this exception is thrown
Since
Qore 0.8.12
nothing Qore::rename ( string  old_path,
string  new_path 
)

Renames (or moves) files or directories. Note that for this call to function properly, the Qore process must have sufficient permissions and access to the given filesystem objects or paths to execute the rename operation.

This function does not return any value; if any errors occur, an exception is thrown.

Restrictions:
Qore::PO_NO_FILESYSTEM
Parameters
old_pathThe original path for the file to move
new_pathThe target path for the file
Example:
1 rename("/tmp/myfile", "/tmp/myfile.txt");
Exceptions
RENAME-ERRORempty string passed for one of the arguments or the operating system returned an error
Note
Some operating systems do not allow moving files between filesystems (ex Solaris)
int Qore::rmdir ( string  path)

Removes a directory.

Restrictions:
Qore::PO_NO_FILESYSTEM
Parameters
paththe path to the directory to remove
Returns
0 if no error occurred; -1 if an error occurred, in which case errno() and/or strerror() can be used to retrieve the error
Example:
1 if (rmdir("/tmp/newdir"))
2  printf("rmdir /tmp/newdir: %s\n", strerror());
See Also
Qore::Dir::rmdir()
*list Qore::stat ( string  path)

Returns a list of file status values for the path argument, following any symbolic links; if any errors occur, NOTHING is returned and errno() can be used to retrieve the error number.

Restrictions:
Qore::PO_NO_FILESYSTEM
Parameters
paththe path to retrieve information for
Returns
a list of file status values for the path argument, following any symbolic links; if any errors occur, NOTHING is returned and errno() can be used to retrieve the error number
Example:
1 *list l = stat("/tmp/file.txt");
2 if (!exists l)
3  printf("could not stat /tmp/file.txt: %s\n", strerror());
See Also
lstat() for a version of this function that does not follow symbolic links

hstat() for a version of this function that returns a user-friendly hash instead of a list

File::stat() for a static method in the File class that throws an exception instead of returning NOTHING when errors occur
nothing Qore::stat ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
RUNTIME_NOOP
*hash Qore::statvfs ( string  path)

Returns a hash of filesystem status values for the file or directory path passed.

Platform Availability:
Qore::Option::HAVE_STATVFS
Restrictions:
Qore::PO_NO_FILESYSTEM
Parameters
paththe path to the filesystem (or on the filesystem)
Returns
a Filesystem Status Hash; or, if any errors occur, NOTHING is returned and errno() can be used to retrieve the error number
Example:
1 *hash h = statvfs("/tmp")
See Also
File::statvfs() for a static method in the File class that throws an exception instead of returning NOTHING when errors occur
nothing Qore::symlink ( string  old_path,
string  new_path 
)

Creates a symbolic link to a directory path. Note that for this call to function properly, the Qore process must have sufficient permissions and access to the given filesystem path to create the symbolic link.

Platform Availability:
Qore::Option::HAVE_UNIX_FILEMGT
Restrictions:
Qore::PO_NO_FILESYSTEM

This function does not return any value; if any errors occur, an exception is thrown. If the target of the symbolic link does not exist, it is not an error; the symbolic link is created anyway.

Parameters
old_pathThe original path; the target of the link
new_pathThe path to the location of the new symbolic link to be created with this function call
Example:
1 symlink("/tmp/temporary-dir", "/users/oracle/install");
Exceptions
SYMLINK-ERRORempty string passed for one of the arguments or the operating system returned an error
Since
Qore 0.8.5
int Qore::umask ( softint  mask)

Sets the file creation mode mask for the process and returns the previous value of the file creation mode mask.

Restrictions:
Qore::PO_NO_PROCESS_CONTROL
Parameters
maskthe new file creation mode mask for the process
Returns
the old file creation mode mask for the process
Example:
1 if (unlink(path))
2  printf("%s: %s\n", path, strerror());
nothing Qore::umask ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
Qore::PO_NO_PROCESS_CONTROL
Code Flags:
RUNTIME_NOOP
int Qore::unlink ( string  path)

Deletes a file and returns 0 for success, -1 for error (in which case errno() can be used to get the error)

Does not delete directories; see rmdir() for a similar function that removes directories

Restrictions:
Qore::PO_NO_FILESYSTEM
Parameters
paththe path to the file to delete
Returns
0 for success, -1 for error (in which case errno() can be used to get the error)
Example:
1 if (unlink(path))
2  printf("%s: %s\n", path, strerror());
nothing Qore::unlink ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
Qore::PO_NO_FILESYSTEM
Code Flags:
RUNTIME_NOOP