Qore Programming Language Reference Manual 0.8.8

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

All Classes Namespaces Functions Variables Groups Pages
Functions
Filesystem Functions

## Functions
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 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 writable by the current user, False if not. More...
bool | Qore::is_writeable (string path)
| Returns True if the string passed identifies a file 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 operated 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...
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

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

  path | the 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

int Qore::chmod | ( | string | path,
|  | softint | mode
| ) |  |

Changes the mode of a file or directory.

Restrictions:
  Qore::PO_NO_FILESYSTEM

Parameters

  path | the path to the file or directory to change
  mode | the 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());

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

  path | path to the file or directory to change
  owner | the uid of the new user owner; -1 means do not change user owner
  group | the 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

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:
  my *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:
  my 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_str | the 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:
  my *list $gl = glob("*.txt");
  if (!exists $gl)
  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

  path | the 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:
  my *hash $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

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

  path | the 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:
  my *hash $h = hstat("/tmp/file.txt");
  if (!exists $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

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

  path | the path to check

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

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

  path | the path to check

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

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

  path | the path to check

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

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

  path | the path to check

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

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

  path | the path to check

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

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

  path | the path to check

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

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

  path | the path to check

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

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

  path | the path to check

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

Example:
  my bool $b = is_pipe("/tmp/mypipe");

bool Qore::is_readable | ( | string | path | ) |

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

Restrictions:
  Qore::PO_NO_FILESYSTEM

Code Flags:
  CONSTANT

Parameters

  path | the path to check

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

Example:
  my bool $b = is_readable("/etc/hosts");

Bug:
  on Windows this function always returns True for directories; this will be fixed in a later version of Qore

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

  path | the path to check

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

Example:
  my bool $b = is_socket("/tmp/X0");

bool Qore::is_writable | ( | string | path | ) |

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

Restrictions:
  Qore::PO_NO_FILESYSTEM

Code Flags:
  CONSTANT

Parameters

  path | the path to check

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

Example:
  my bool $b = is_writable("/etc/hosts");

Bug:
  on Windows this function always returns False for directories; this will be fixed in a later version of Qore

bool Qore::is_writeable | ( | string | path | ) |

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

Restrictions:
  Qore::PO_NO_FILESYSTEM

Code Flags:
  CONSTANT

Parameters

  path | the path to check

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

Example:
  my bool $b = is_writeable("/etc/hosts");

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 operated on the symbolic link itself.

Platform Availability:
  Qore::Option::HAVE_UNIX_FILEMGT

Restrictions:
  Qore::PO_NO_FILESYSTEM

Parameters

  path | path to the file or directory to change
  uid | the uid of the new user owner; -1 means do not change user owner
  gid | the 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)

*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

  path | the 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:
  my *list $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

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

  path | the path to the directory to create
  mode | the 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:
  if (mkdir("/tmp/newdir", 0755))
  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

  path | the path to the new named pipe
  mode | the 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());

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

  path | the 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:
  my string $str = readlink("/tmp/symbolic_link");

Exceptions

  READLINK-ERROR | Invalid arguments or a system error occured (ex: file does not exist or is not a symbolic link)

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_path | The original path for the file to move
  new_path | The target path for the file

Example:
  rename("/tmp/myfile", "/tmp/myfile.txt");

Exceptions

  RENAME-ERROR | empty 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

  path | the 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());

*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

  path | the 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:
  my *list $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

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

  path | the 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:
  my *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_path | The original path; the target of the link
  new_path | The 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-ERROR | empty 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

  mask | the 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());

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

  path | the 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());

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