file_system
|
 |
The os_file_system
class is comprised wholly of static functions for access and manipulation of
information associated with a particular path in a file system.
Declaration
#include <ospace/file/filesys.h>
class os_file_system
Interface
exists
/*
static */ bool exists( const string& path
, enum Encoding enc = Ascii )
Returns
true if path is
accessible by the current process; that is, if the directories mentioned in path
exist and can be searched, and the rightmost name (the final directory name
or the file name) exists. Default enc is Ascii. Valid value for enc can be Ascii or Utf8.
remove
/*
static */ void remove( const string& path
, enum Encoding enc = Ascii)
Removes
path from the file system. Operates on regular
files, directories, and some special files. It calls os_io_status which
can raise os_io_tollkit_error::system_call_failure. Default enc is Ascii. Valid value for enc can be Ascii or Utf8.
remove_if_exists
/*
static */ void remove_if_exists( const string& path
, enum Encoding enc = Ascii)
If
path exists, removes it. Checks for the existence
of path and conditionally calls remove
. Unlike remove() , this function does not
generate errors if path does not exist; however,
events for other conditions, such as permissions, can occur. Default enc is Ascii. Valid value for enc can be Ascii or Utf8.
Throws: os_file_toolkit_error
rename
/*
static */ void rename( const string& from
, const string& to
, enum Encoding enc = Ascii)
Renames
the path from from to to
. Whether or not this function permits a different file system destination
is implementation-dependent. Default enc is Ascii. Valid value for enc can be Ascii or Utf8.
Throws: os_file_toolkit_error
resize
/*
static */ void resize( const string& path
, os_off_t length
)
Resizes
path to length bytes. If
the length of the file is less than length bytes,
the call attempts to increase the file size. Note that this function is
implementation-dependent. When this function is allowed, the gap in the
resulting file will read as zeros. This function is only valid for paths to
regular files.
Throws: os_file_toolkit_error
status
/*
static */ os_io_status status( const string& path
)
Returns
the status associated with path . See class os_io_status
for more information.
Throws: os_file_toolkit_error
UNIX-Specific Interface
executable
/*
static */ bool executable( const string& path
)
Tests
whether path has execute permission based on the
real rather than the effective user and group IDs.
limit
/*
static */ long limit( const string& path
, int limit
)
Returns
the limit of type limit associated with
path . This function is a wrapper around the pathconf
system call. Consult your UNIX documentation for the various values of limit
.
Throws: os_file_toolkit_error
link
/*
static */ void link( const string& to ,
const string& from )
Creates
a hard link or duplicate entry to the same inode
from from to to .
Throws: os_file_toolkit_error
readable
/*
static */ bool readable( const string& path
)
Returns
true if the permissions for path
indicate readability based on the real rather than the effective user ID and
group.
symbolic_link
/*
static */ string symbolic_link( const string& path
)
Returns
the path associated with the symbolic link named by path
. A system error is generated if path is not the name of a symbolic link or
is not accessible.
Note that this function
has a hard-coded limit for the return value length. If the limit is
insufficient, a system error is generated. To alter the limit, change the
value of max_path_length in <ospace/file/filesys.h>
and recompile the library.
Throws: os_file_toolkit_error
symbolic_link
/*
static */ void symbolic_link( const string& to
, const string& from
)
Creates
a symbolic link from from to to
.
Throws: os_file_toolkit_error
symbolic_link_status
/*
static */ os_io_status symbolic_link_status( const string& path
)
This
function is the same as status() . However,
when path refers to a symbolic link the status is
returned for the link.
Throws: os_file_toolkit_error
writable
/*
static */ bool writable( const string& path
)
Returns
true if the user has permissions to write to path
based on the real rather than the effective user ID and group.
Copyright©1994-2026 Recursion
Software LLC
All Rights Reserved - For use by licensed users only.