Qore Programming Language Reference Manual  0.9.3.2
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< stringQore::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< StatInfoQore::hlstat (string path)
 Returns a StatInfo hash 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< StatInfoQore::hstat (string path)
 Returns a StatInfo hash 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< auto > 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, bool parents=False)
 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< auto > 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< FilesystemInfoQore::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

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

Function Documentation

◆ absolute_path()

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:
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

◆ absolute_path_unix()

bool Qore::absolute_path_unix ( string  path)

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

Code Flags:
CONSTANT
Example:
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

◆ absolute_path_windows()

bool Qore::absolute_path_windows ( string  path)

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

Code Flags:
CONSTANT
Example:
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

◆ chdir()

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:
if (chdir(dir))
printf("chdir %s: %s\n", dir, strerror());
Since
Qore 0.8.4 this function is tagged with Qore::PO_NO_PROCESS_CONTROL

◆ chmod()

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:
if (chmod("/bin/login", 0755))
printf("rmdir /tmp/newdir: %s\n", strerror());

◆ chown()

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:
if (chown("/bin/login", 0, 0))
printf("chown /bin/login: %s\n", strerror());
See also
lchown() for a version of this function that does not follow symbolic links

◆ getcwd()

*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:
*string cwd = getcwd();
See also
getcwd2() for a similar function that throws an exception if an error occurs instead

◆ getcwd2()

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:
string cwd = getcwd2();
See also
getcwd() for a similar function that returns NOTHING instead of throwing an exception if an error occurs

◆ glob() [1/2]

*list<string> 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:
*list<string> gl = glob("*.txt");
if (!gl)
printf("failed to glob *.txt: %s\n", strerror());

◆ glob() [2/2]

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

◆ hlstat() [1/2]

*hash<StatInfo> Qore::hlstat ( string  path)

Returns a StatInfo hash 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 StatInfo hash providing information about the path argument, not following any symbolic links; if any errors occur (such as if the target path is not readable or the file does not exist for example), NOTHING is returned and errno() can be used to retrieve the error number
Example:
*hash<StatInfo> h = hlstat("/tmp/file.txt");
if (!exists h)
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

◆ hlstat() [2/2]

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

◆ hstat() [1/2]

*hash<StatInfo> Qore::hstat ( string  path)

Returns a StatInfo hash 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 StatInfo hash providing information about the path argument, following any symbolic links; if any errors occur (such as if the target path is not readable or the file does not exist for example), NOTHING is returned and errno() can be used to retrieve the error number
Example:
*hash<StatInfo> h = hstat("/tmp/file.txt");
if (!h)
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

◆ hstat() [2/2]

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

◆ is_bdev()

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:
bool b = is_bdev("/tmp/sda1");

◆ is_cdev()

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:
bool b = is_cdev("/tmp/tty");

◆ is_dev()

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:
bool b = is_dev("/tmp/scanner");

◆ is_dir()

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:
bool b = is_dir("/tmp/mydir");

◆ is_executable()

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:
bool b = is_executable("/bin/login");

◆ is_file()

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:
bool b = is_file("/etc/hosts");

◆ is_link()

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:
bool b = is_link("/etc/hosts");

◆ is_pipe()

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:
bool b = is_pipe("/tmp/mypipe");

◆ is_readable()

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:
bool b = is_readable("/etc/hosts");

◆ is_socket()

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:
bool b = is_socket("/tmp/X0");

◆ is_writable()

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:
bool b = is_writable("/etc/hosts");
Since
Qore 0.8.12 this function works properly on Windows

◆ is_writeable()

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:
bool b = is_writeable("/etc/hosts");
Since
Qore 0.8.12 this function works properly on Windows

◆ lchown()

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:
if (lchown("/tmp/socket", 0, 0))
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)

◆ lstat() [1/2]

*list<auto> 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:
*list<auto> l = lstat("/tmp/file.txt");
if (!exists l)
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

◆ lstat() [2/2]

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

◆ mkdir()

int Qore::mkdir ( string  path,
softint  mode = 0777,
bool  parents = False 
)

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)
parentsif True then parent directories are created
Returns
if no error occurred returns 0 or the count of newly created directory when parents = True; -1 if an error occurred, in which case errno() and/or strerror() can be used to retrieve the error
Example:
if (mkdir("/tmp/newdir", 0755))
printf("mkdir /tmp/newdir: %s\n", strerror());
See also
umask()
Since
Qore 0.8.13 added the parents parameter

◆ mkfifo()

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:
if (mkfifo("/tmp/pipe"))
printf("mkfifo /tmp/pipe: %s\n", strerror());

◆ readlink()

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:
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)

◆ realpath()

string Qore::realpath ( string  path)

Returns the canonicalized absolute pathname from the given path.

Restrictions:
Qore::PO_NO_FILESYSTEM
Example:
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

◆ rename()

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:
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)

◆ rmdir()

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:
if (rmdir("/tmp/newdir"))
printf("rmdir /tmp/newdir: %s\n", strerror());
See also
Qore::Dir::rmdir()

◆ stat() [1/2]

*list<auto> 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:
*list<auto> l = stat("/tmp/file.txt");
if (!exists l)
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

◆ stat() [2/2]

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

◆ statvfs()

*hash<FilesystemInfo> 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 FilesystemInfo hash; or, if any errors occur, NOTHING is returned and errno() can be used to retrieve the error number
Example:
*hash<FilesystemInfo> 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

◆ symlink()

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:
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

◆ umask() [1/2]

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:
if (unlink(path))
printf("%s: %s\n", path, strerror());

◆ umask() [2/2]

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

◆ unlink() [1/2]

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:
if (unlink(path))
printf("%s: %s\n", path, strerror());

◆ unlink() [2/2]

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