Interface
Constructor
os_directory()
Constructs
a directory that is closed.
Constructor
os_directory(
const string& dirpath
, os_open_t control
, enum Encoding enc = Ascii )
Constructs
a reference to the directory with name dirpath using
the control (default O_OPEN
) flags. Default enc is Ascii. Valid value for enc can be Ascii or Utf8.
Destructor
~os_directory()
Destroys
the directory. If the directory is open, closes it.
<
bool
operator<( const os_directory& directory
) const
Returns
true if handle is less than directory
. Note that this orders open os_directory
objects in a way that is not based on their names.
==
bool
operator==( const os_directory& directory
)
const
Returns
true if handle is the same as directory
.
(os_dir_t)
operator
os_dir_t() const
Returns a copy of os_dir_t
value.
close
void
close()
Closes
the directory.
Throws: os_file_toolkit_error
contains
bool
contains( const string& filename , enum Encoding enc = Ascii )
const
Returns
true if the directory contains filename
. For repeated existence tests, obtain a list once with filenames()
rather than repeatedly using this function. Default enc is Ascii. Valid value for enc can be Ascii or Utf8.
Throws: os_file_toolkit_error
create
/*
static */ void create( const string&
dirpath , enum Encoding enc = Ascii )
Creates
a new directory called dirpath . Default enc is Ascii. Valid value for enc can be Ascii or Utf8.
Throws: os_file_toolkit_error
descriptor
os_desc_t
descriptor() const
Returns
the directory's primitive file descriptor or OS_UNDEFINED
if the directory is not open. Also see descriptor()
.
exists
/*
static */ bool exists( const string& dirpath
, enum Encoding enc = Ascii )
Returns
true if dirpath is
accessible by the current process. Default enc is Ascii. Valid value for enc can be Ascii or Utf8.
Throws: os_file_toolkit_error
filename_limit
/*
static */ long filename_limit( const string& dirpath
, enum Encoding enc = Ascii )
Returns
the maximum number of characters allowed in a base name if a file is placed
in the directory dirpath . Default enc is Ascii. Valid value for enc can be Ascii or Utf8.
filenames
vector<
string > filenames( enum Encoding enc = Ascii ) const
Returns
a vector of the directory's filenames. Default enc is Ascii. Valid value for enc can be Ascii or Utf8.
Throws: os_file_toolkit_error
is_open
bool
is_open() const
Returns true
if the directory is open.
no_truncate
/*
static */ bool no_truncate( const string& dirpath
)
Returns
true if the system is configured to err on
filenames in dirpath that are longer than the
maximum filename length; returns false if the
system is configured to truncate filenames in dirpath
that exceed the maximum length.
Throws: os_file_toolkit_error
open
void
open( const string& dirpath ,
os_open_t control , enum Encoding enc = Ascii )
Opens
a directory called dirpath using the control
(default O_OPEN ) flags. Default enc is Ascii. Valid value for enc can be Ascii or Utf8.
Throws: os_file_toolkit_error
pathname_limit
/*
static */ long pathname_limit( const string& dirpath
)
Returns
the maximum number of characters allowed in a complete path name including
the base filename interpreted as a relative path from the directory dirpath
.
print
void
print( ostream& stream
) const
Prints
descriptor to stream . If the directory is not
open, prints unopened . Also see descriptor()
.
remove
/*
static */ void remove( const string&
dirpath , enum Encoding enc = Ascii )
Removes the file object dirpath
. Default enc is Ascii. Valid value for enc can be Ascii or Utf8.
Throws: os_file_toolkit_error
rename
/*
static */ void rename( const string& old
, const string& new
, bool overwrite
, enum Encoding enc = Ascii )
Renames the old
file object to new and destroys any existing file
or directory if overwrite (default false
) is true . Default enc is Ascii. Valid value for enc can be Ascii or Utf8.
Throws: os_file_toolkit_error
short_filenames
vector<
string > short_filenames( enum Encoding enc = Ascii ) const
Returns
a vector of filenames in short format. This method is useful for Win32
platforms. Default enc is Ascii. Valid value for enc can be Ascii or Utf8.
Throws: os_file_toolkit_error
status
os_io_status
status() const
Returns
an os_io_status object constructed on the open
file descriptor.
UNIX-Specific Interface
Constructor
os_directory(
const string& dirpath ,
os_open_t control ,
os_mode_t mode )
Constructs
a directory with name dirpath and mode mode
using the open flags control . See open()
for error conditions and other information.
chown_restricted
/*
static */ bool chown_restricted( const string& dirpath
)
Returns
true if the system is configured to disallow
ownership changes to non-directory files in dirpath
by anyone except a superuser; returns false if
the current process can change the owner of entries of dirpath
if the process has file and directory access permissions.
Throws: os_file_toolkit_error
create
/*
static */ void create( const string&
dirpath ,
os_mode_t mode )
Creates
a new directory called dirpath with mode mode
.
Throws: os_file_toolkit_error
io_control
os_ioctl_t
io_control() const
Returns the current I/O
control flag value.
io_control
void
io_control( os_ioctl_t control )
Sets the I/O control flag
value to control .
open
void
open( const string& dirpath
, os_open_t control
, os_mode_t mode
)
Opens
a directory called dirpath with mode mode
using the open flags control .
Throws: os_file_toolkit_error
pipe_buffer_limit
/* static */ long
pipe_buffer_limit( const string&
dirpath )
Returns
the maximum number of bytes that can be automatically written to a named
pipe placed in the directory dirpath .