A representation of a file in the filesystem. More...
#include <File.h++>

Public Member Functions | |
| File (const String &path) | |
| Construct a new File with the given path. | |
| virtual | ~File () throw () |
| Destructor. | |
| void | open (IOMode mode=IOReadWrite, FileOpenMode openMode=FileOpenElseCreate, const Permissions &perm=Permissions::USER_READ_WRITE) throw (IOException) |
| Open the file. | |
| bool | exists () const throw () |
| Test if the file exists. | |
| bool | isDirectory () const throw () |
| Test if the file is a directory. | |
| bool | isFile () const throw () |
| Test if the file is a plain file. | |
| bool | isPipe () const throw () |
| Test if the file is a pipe or socket. | |
| bool | isSymLink () const throw () |
| Test if the file is a symbolic link. | |
| bool | touch () throw () |
| Touch the file. | |
| bool | remove () throw () |
| Remove the file. | |
| bool | setPermissions (const Permissions &perm) throw () |
| Set the file permissions. | |
| bool | getPermissions (Permissions &perm) throw () |
| Get the file permissions. | |
| bool | lockRange (uint64_t start, uint64_t length, LockType type, bool wait=true) throw () |
| Lock a range of bytes in the file. | |
| bool | unlockRange (uint64_t start, uint64_t length) throw () |
| Unlock a range of bytes in the file. | |
| void | truncate (uint64_t size=0) throw (IOException) |
| Truncate the file to a given size. | |
| String | getPath () const |
| Get the pathname for the file. | |
| int64_t | getSize () throw (IOException) |
| Get the size of the file. | |
| virtual size_t | read (ByteBuffer &buffer) throw (IOException) |
| Read data from the stream into a ByteBuffer. | |
| virtual size_t | read (CharBuffer &buffer) throw (IOException) |
| Read data from the stream into a CharBuffer. | |
| template<typename T > | |
| size_t | read (Buffer< T > &buffer, size_t &partial) throw (IOException) |
| Read data from the stream into a Buffer of arbitrary type. | |
| virtual size_t | read (byte_t *buffer, size_t buflen) throw (IOException) |
| Read data from the stream into a raw buffer. | |
| size_t | read (byte_t *buffer, size_t buflen, int64_t offset, AsyncIOTask &task) throw (IOException) |
| Read data asynchronously from the stream into a raw buffer. | |
| size_t | read (ByteBuffer &buffer, int64_t offset, AsyncIOTask &task) throw (IOException) |
| Read data asynchronously from the stream into a Buffer. | |
| virtual size_t | read (MemoryBlock *vec, uint_t count) throw (IOException) |
| Read data from the stream into a series of I/O buffers. | |
| size_t | write (const byte_t *buffer, size_t buflen, int64_t offset, AsyncIOTask &task) throw (IOException) |
| Write data asynchronously to the stream from a raw buffer. | |
| size_t | write (ByteBuffer &buffer, int64_t offset, AsyncIOTask &task) throw (IOException) |
| Write data asynchronously to the stream from a Buffer. | |
| virtual size_t | write (ByteBuffer &buffer) throw (IOException) |
| Write data to the stream from a ByteBuffer. | |
| virtual size_t | write (CharBuffer &buffer) throw (IOException) |
| Write data to the stream from a CharBuffer. | |
| template<typename T > | |
| size_t | write (Buffer< T > &buffer, size_t &partial) throw (IOException) |
| Write data to the stream from a Buffer of arbitrary type. | |
| virtual size_t | write (const byte_t *buffer, size_t buflen) throw (IOException) |
| Write data to the stream from a raw buffer, until either the entire buffer is written or an error or timeout occurs. | |
| virtual size_t | write (const MemoryBlock *vec, uint_t count) throw (IOException) |
| Write data to the stream from a series of I/O buffers. | |
| virtual size_t | readFully (ByteBuffer &buffer, size_t count=0) throw (IOException) |
| Read data from the stream into a ByteBuffer, until either the buffer is full or an error or timeout occurs. | |
| virtual size_t | readFully (CharBuffer &buffer, size_t count=0) throw (IOException) |
| Read data from the stream into a CharBuffer, until either the buffer is full or an error or timeout occurs. | |
| template<typename T > | |
| size_t | readFully (Buffer< T > &buffer, size_t &partial) throw (IOException) |
| Read data from the stream into a Buffer of arbitrary type, until either the buffer is full or an error or timeout occurs. | |
| virtual size_t | readFully (byte_t *buffer, size_t buflen) throw (IOException) |
| Read data from the stream into a raw buffer, until either the buffer is full or an error or timeout occurs. | |
| virtual size_t | writeFully (ByteBuffer &buffer) throw (IOException) |
| Write data to the stream from a ByteBuffer, until either the entire buffer is written or an error or timeout occurs. | |
| virtual size_t | writeFully (CharBuffer &buffer) throw (IOException) |
| Write data to the stream from a CharBuffer, until either the entire buffer is written or an error or timeout occurs. | |
| template<typename T > | |
| size_t | writeFully (Buffer< T > &buffer, size_t &partial) throw (IOException) |
| Write data to the stream from a Buffer of arbitrary type, until either the entire buffer is written or an error or timeout occurs. | |
| virtual size_t | writeFully (const byte_t *buffer, size_t buflen) throw (IOException) |
| Write data to the stream from a raw buffer. | |
| virtual int64_t | seek (int64_t offset, SeekMode mode=SeekAbsolute) throw (IOException) |
| Reposition the seek pointer in the stream. | |
| virtual int64_t | tell () throw (IOException) |
| Get the current (absolute) offset of the seek pointer. | |
| bool | isOpen () const throw () |
| Test if the stream is open. | |
| bool | isSeekable () const throw () |
| Test if the stream supports seeking. | |
| bool | isReadable () const throw () |
| Test if the stream can be read from. | |
| bool | isWritable () const throw () |
| Test if the stream can be written to. | |
| bool | isFullDuplex () const throw () |
| Test if the stream is full-duplex (i.e., supports both reading and writing). | |
| bool | isHalfDuplex () const throw () |
| Test if the stream is half-duplex (i.e., supports either reading or writing, but not both). | |
| virtual void | close (IOMode mode=IOReadWrite) throw () |
| Close the stream for reading, writing, or both. | |
| virtual void | setTimeout (timespan_ms_t timeout) throw (IOException) |
| Set the stream I/O timeout, in milliseconds. | |
| timespan_ms_t | getTimeout () const throw () |
| Get the stream I/O timeout, in milliseconds. | |
Static Public Member Functions | |
| static bool | makeDirectory (const String &path, bool createAll=false, const Permissions &perm=Permissions::defaultDirPerms) throw () |
| Create a directory. | |
| static bool | remove (const String &path) throw () |
| Remove a file. | |
| static bool | removeDirectory (const String &path) throw () |
| Remove a directory. | |
| static bool | removeDirectoryTree (const String &path) |
| Recursively remove all files and directories rooted at a given directory. | |
| static bool | exists (const String &path) throw () |
| Test a file for existence. | |
| static bool | isDirectory (const String &path) throw () |
| Test if a file is a directory. | |
| static bool | isFile (const String &path) throw () |
| Test if a file is a plain file. | |
| static bool | isPipe (const String &path) throw () |
| Test if a file is a pipe or socket. | |
| static bool | isSymLink (const String &path) throw () |
| Test if a file is a symbolic link. | |
| static bool | readSymLink (String &path) throw () |
| Read a symbolic link. | |
| static bool | resolveSymLink (String &path) throw () |
| Resolve a symbolic link. | |
| static bool | createLink (const String &oldPath, const String &newPath, bool hardLink=false) throw () |
| Create a hard or soft link to an existing file. | |
| static bool | setPermissions (const String &path, const Permissions &perm) throw () |
| Set the permissions on a file. | |
| static bool | getPermissions (const String &path, Permissions &perm) throw () |
| Get the permissions for a file. | |
| static bool | getAttributes (const String &path, FileAttributes &attrs) throw () |
| Get file attributes. | |
| static int64_t | getSize (const String &path) throw () |
| Get the size of a file. | |
| static bool | rename (const String &oldName, const String &newName) throw () |
| Rename a file. | |
| static bool | copy (const String &oldFile, const String &newFile) throw () |
| Copy a file to another file. | |
| static bool | move (const String &oldFile, const String &newFile) throw () |
| Move a file or directory to another location within the same volume or filesystem. | |
| static bool | touch (const String &path) throw () |
| Touch a file. | |
| static void | getFileSystemRoots (StringVec &roots, bool localOnly=true) throw () |
| Get the filesystem roots. | |
| static void | setCreationMask (const Permissions &perm) throw () |
| Set the file creation mask for the current process. | |
| static uint64_t | getDiskFreeSpace (const String &path) throw () |
| Get the amount of free space, in bytes, on the disk or filesystem associated with the given path. | |
| static size_t | getDiskBlockSize (const String &path) throw () |
| Get the disk block size, in bytes, on the disk or filesystem associated with the given path. | |
| static int64_t | roundSizeToBlockSize (const int64_t &fileSize, size_t blockSize) |
| Round a file size to the next higher multiple of the given block size. | |
| static String | removeTrailingSeparators (const String &path) throw () |
| Remove trailing file separators from a file path. | |
| static bool | isValidSeparator (char c) throw () |
| Determine if a given character is a valid file separator for the host system. | |
Static Public Attributes | |
| static const char | separator = FS |
| The host system's file separator character. | |
| static const char | validSeparators [] |
| A string containing all valid file separator characters for the host system. | |
| static const char | separatorString [] = { File::separator, NUL } |
| The host system's file separator character, as a string. | |
| static const char * | eol = EOL |
| The host system's end-of-line character sequence. | |
| static const uint_t | MAX_IOBLOCK_COUNT = 16 |
| The maximum number of I/O buffers that can be passed to the vector I/O methods. | |
Protected Member Functions | |
| void | _init (FileHandle handle, bool seekable, bool readable, bool writable) |
| Initialize the stream for use with an open file. | |
Protected Attributes | |
| String | _name |
A representation of a file in the filesystem.
The class also provides some static filesystem-related utility functions.
| ~File | ( | ) | throw () [virtual] |
Destructor.
| void _init | ( | FileHandle | handle, | |
| bool | seekable, | |||
| bool | readable, | |||
| bool | writable | |||
| ) | [protected, inherited] |
Initialize the stream for use with an open file.
| handle | The handle to an open file. | |
| seekable | A flag indicating whether the stream is seekable. | |
| readable | A flag indicating whether the stream is readable. | |
| writable | A flag indicating whether the stream is writable. |
| void close | ( | IOMode | mode = IOReadWrite |
) | throw () [virtual, inherited] |
Close the stream for reading, writing, or both.
| mode | The close mode. |
Reimplemented in StreamPipe, and StreamSocket.
Copy a file to another file.
| oldFile | The source file. | |
| newFile | The target file. |
| bool createLink | ( | const String & | oldPath, | |
| const String & | newPath, | |||
| bool | hardLink = false | |||
| ) | throw () [static] |
Create a hard or soft link to an existing file.
| oldPath | The path to the existing file. | |
| newPath | The path of the link. | |
| hardLink | A flag indicating whether the link should be a hard link or soft (symbolic) link. Windows only supports hard links, so attempts to create a symbolic link on that platform will fail. |
| bool exists | ( | const String & | path | ) | throw () [static] |
Test a file for existence.
| path | The path of the file. |
| bool exists | ( | ) | const throw () |
Test if the file exists.
| bool getAttributes | ( | const String & | path, | |
| FileAttributes & | attrs | |||
| ) | throw () [static] |
Get file attributes.
| path | The file. | |
| attrs | The FileAttributes object into which the file's attributes should be placed. |
| size_t getDiskBlockSize | ( | const String & | path | ) | throw () [static] |
Get the disk block size, in bytes, on the disk or filesystem associated with the given path.
| path | The path. On POSIX systems, the path can refer to any file; the value returned will be the amount of free space on the disk partition containing that file. On Windows systems, the path should be one of the filesystem roots as returned by getFileSystemRoots(). |
| uint64_t getDiskFreeSpace | ( | const String & | path | ) | throw () [static] |
Get the amount of free space, in bytes, on the disk or filesystem associated with the given path.
| path | The path. On POSIX systems, the path can refer to any file; the value returned will be the amount of free space on the disk partition containing that file. On Windows systems, the path should be one of the filesystem roots as returned by getFileSystemRoots(). |
| void getFileSystemRoots | ( | StringVec & | roots, | |
| bool | localOnly = true | |||
| ) | throw () [static] |
Get the filesystem roots.
On POSIX systems there is only one root, namely "/". On Windows, there are multiple roots, corresponding to the mapped drive letters such as "C:", "D:", etc.
| roots | The vector in which to place the roots. | |
| localOnly | A flag indicating that only roots corresponding to local (non-read-only, non-networked) disks should be returned. This option is only significant on Windows. |
| String getPath | ( | ) | const [inline] |
Get the pathname for the file.
| bool getPermissions | ( | const String & | path, | |
| Permissions & | perm | |||
| ) | throw () [static] |
Get the permissions for a file.
| path | The file. | |
| perm | The Permissions object into which the file's permissions should be placed. |
| bool getPermissions | ( | Permissions & | perm | ) | throw () |
Get the file permissions.
(NOTE: this call is very slow on Windows.)
| perm | The Permissions object into which the file's permissions should be placed. |
| int64_t getSize | ( | const String & | path | ) | throw () [static] |
Get the size of a file.
| path | The file. |
| int64_t getSize | ( | ) | throw (IOException) |
| timespan_ms_t getTimeout | ( | ) | const throw () [inline, inherited] |
Get the stream I/O timeout, in milliseconds.
| bool isDirectory | ( | const String & | path | ) | throw () [static] |
Test if a file is a directory.
| path | The path of the file. |
| bool isDirectory | ( | ) | const throw () |
Test if the file is a directory.
| bool isFile | ( | const String & | path | ) | throw () [static] |
Test if a file is a plain file.
| path | The path of the file. |
| bool isFile | ( | ) | const throw () |
Test if the file is a plain file.
| bool isFullDuplex | ( | ) | const throw () [inline, inherited] |
Test if the stream is full-duplex (i.e., supports both reading and writing).
| bool isHalfDuplex | ( | ) | const throw () [inline, inherited] |
Test if the stream is half-duplex (i.e., supports either reading or writing, but not both).
| bool isOpen | ( | ) | const throw () [inline, inherited] |
Test if the stream is open.
| bool isPipe | ( | const String & | path | ) | throw () [static] |
Test if a file is a pipe or socket.
| path | The path of the file. |
| bool isPipe | ( | ) | const throw () |
Test if the file is a pipe or socket.
| bool isReadable | ( | ) | const throw () [inline, inherited] |
Test if the stream can be read from.
| bool isSeekable | ( | ) | const throw () [inline, inherited] |
Test if the stream supports seeking.
| bool isSymLink | ( | const String & | path | ) | throw () [static] |
Test if a file is a symbolic link.
(Some platforms do not support symbolic links.)
| path | The path of the file. |
| bool isSymLink | ( | ) | const throw () |
Test if the file is a symbolic link.
(Some platforms do not support symbolic links.)
| bool isValidSeparator | ( | char | c | ) | throw () [static] |
Determine if a given character is a valid file separator for the host system.
| bool isWritable | ( | ) | const throw () [inline, inherited] |
Test if the stream can be written to.
| bool lockRange | ( | uint64_t | start, | |
| uint64_t | length, | |||
| LockType | type, | |||
| bool | wait = true | |||
| ) | throw () |
Lock a range of bytes in the file.
The type of lock may be mandatory or advisory, depending on what the host system supports.
| start | The start offset of the range to lock. | |
| length | The length of the range to lock. | |
| type | The type of lock. | |
| wait | A flag indicating whether the method should block until the lock is acquired, or return immediately if it can't be. |
| bool makeDirectory | ( | const String & | path, | |
| bool | createAll = false, |
|||
| const Permissions & | perm = Permissions::defaultDirPerms | |||
| ) | throw () [static] |
Create a directory.
| path | The path to the new directory. | |
| createAll | A flag indicating whether any nonexsitent intermediate directories in path should also be created. | |
| perm | The permissions to assign to the new directory. |
Move a file or directory to another location within the same volume or filesystem.
| oldFile | The source file. | |
| newFile | The target location. |
| void open | ( | IOMode | mode = IOReadWrite, |
|
| FileOpenMode | openMode = FileOpenElseCreate, |
|||
| const Permissions & | perm = Permissions::USER_READ_WRITE | |||
| ) | throw (IOException) |
Open the file.
| mode | The I/O mode. | |
| openMode | The file open mode. | |
| perm | The permissions for the file, if the file is being created. |
| size_t read | ( | MemoryBlock * | vec, | |
| uint_t | count | |||
| ) | throw (IOException) [virtual, inherited] |
Read data from the stream into a series of I/O buffers.
This operation is known as "vector read" or "scatter read." The buffers are read into in order. On systems that support it, the operation is performed with a single system call.
| vec | An array of buffers to read into. | |
| count | The number of buffers in the array. |
| IOException | If the end-of-file was reached or some other I/O error occurred. |
Reimplemented in StreamSocket.
| size_t read | ( | ByteBuffer & | buffer, | |
| int64_t | offset, | |||
| AsyncIOTask & | task | |||
| ) | throw (IOException) [inherited] |
Read data asynchronously from the stream into a Buffer.
| buffer | The Buffer to read into. This object must not be destroyed before the asynchronous I/O operation is completed or cancelled. | |
| offset | The file offset to read from. | |
| task | The async I/O control block for monitoring the operation. |
| IOException | If an I/O error occurred. |
Reimplemented in StreamSocket.
| size_t read | ( | byte_t * | buffer, | |
| size_t | buflen, | |||
| int64_t | offset, | |||
| AsyncIOTask & | task | |||
| ) | throw (IOException) [inherited] |
Read data asynchronously from the stream into a raw buffer.
| buffer | The buffer to read into. | |
| buflen | The number of bytes to read. | |
| offset | The file offset to read from. | |
| task | The async I/O control block for monitoring the operation. |
| IOException | If an I/O error occurred. |
Reimplemented in StreamSocket.
| size_t read | ( | byte_t * | buffer, | |
| size_t | buflen | |||
| ) | throw (IOException) [virtual, inherited] |
Read data from the stream into a raw buffer.
| buffer | The buffer to read into. | |
| buflen | The number of bytes to read. |
| IOException | If the end-of-file was reached or some other I/O error occurred. |
Reimplemented in StreamSocket.
| size_t read | ( | Buffer< T > & | buffer, | |
| size_t & | partial | |||
| ) | throw (IOException) [inline, inherited] |
Read data from the stream into a Buffer of arbitrary type.
If sizeof(T) is greater than 1 byte, then there can be no guarantee that the number of bytes read before a timeout or error occurs will be evenly divisible by sizeof(T). If the final element was partially read, the number of bytes of the element that were read will be stored in partial; this value should be passed unmodified to the next invocation of this method to continue reading from the appropriate offset within the partially-read element.
| buffer | The buffer to read into. | |
| partial | The number of bytes remaining to read for a partially-read element; on return, the number of bytes read of a partially-read element, or 0 if the last element was read completely. Should be set to 0 prior to the first call to this method for a fresh buffer. |
| IOException | If the end-of-file was reached or some other I/O error occurred. |
| size_t read | ( | CharBuffer & | buffer | ) | throw (IOException) [virtual, inherited] |
Read data from the stream into a CharBuffer.
| buffer | The buffer to read into. |
| IOException | If the end-of-file was reached or some other I/O error occurred. |
Reimplemented in StreamSocket.
| size_t read | ( | ByteBuffer & | buffer | ) | throw (IOException) [virtual, inherited] |
Read data from the stream into a ByteBuffer.
| buffer | The buffer to read into. |
| IOException | If the end-of-file was reached or some other I/O error occurred. |
Reimplemented in StreamSocket.
| size_t readFully | ( | byte_t * | buffer, | |
| size_t | buflen | |||
| ) | throw (IOException) [virtual, inherited] |
Read data from the stream into a raw buffer, until either the buffer is full or an error or timeout occurs.
| buffer | The buffer to read into. | |
| buflen | The number of bytes to read. |
| IOException | If the end-of-file was reached or some other I/O error occurred. |
| size_t readFully | ( | Buffer< T > & | buffer, | |
| size_t & | partial | |||
| ) | throw (IOException) [inline, inherited] |
Read data from the stream into a Buffer of arbitrary type, until either the buffer is full or an error or timeout occurs.
If sizeof(T) is greater than 1 byte, then there can be no guarantee that the number of bytes read before a timeout or error occurs will be evenly divisible by sizeof(T). If the final element was partially read, the number of bytes of the element that were read will be stored in partial; this value should be passed unmodified to the next invocation of this method to continue reading from the appropriate offset within the partially-read element.
| buffer | The buffer to read into. | |
| partial | The number of bytes remaining to read for a partially-read element; on return, the number of bytes read of a partially-read element, or 0 if the last element was read completely. Should be set to 0 prior to the first call to this method for a fresh buffer. |
| IOException | If the end-of-file was reached or some other I/O error occurred. |
| size_t readFully | ( | CharBuffer & | buffer, | |
| size_t | count = 0 | |||
| ) | throw (IOException) [virtual, inherited] |
Read data from the stream into a CharBuffer, until either the buffer is full or an error or timeout occurs.
| buffer | The buffer to read into. | |
| count | The number of characters to read. If 0 or greater than the number of bytes between the position and the limit, reads up to the limit. |
| IOException | If the end-of-file was reached or some other I/O error occurred. |
| size_t readFully | ( | ByteBuffer & | buffer, | |
| size_t | count = 0 | |||
| ) | throw (IOException) [virtual, inherited] |
Read data from the stream into a ByteBuffer, until either the buffer is full or an error or timeout occurs.
| buffer | The buffer to read into. | |
| count | The number of bytes to read. If 0 or greater than the number of bytes between the position and the limit, reads up to the limit. |
| IOException | If the end-of-file was reached or some other I/O error occurred. |
| bool readSymLink | ( | String & | path | ) | throw () [static] |
Read a symbolic link.
| path | The path to the symbolic link. On return, the literal path to the file to which the link points (relative to the link itself). |
| bool remove | ( | const String & | path | ) | throw () [static] |
Remove a file.
| path | The path to the file. |
| bool remove | ( | ) | throw () |
Remove the file.
| bool removeDirectory | ( | const String & | path | ) | throw () [static] |
Remove a directory.
Only empty directories may be removed using this function.
| path | The path to the directory. |
| bool removeDirectoryTree | ( | const String & | path | ) | [static] |
Recursively remove all files and directories rooted at a given directory.
The removal process will not be interrupted if any errors are encountered.
| path | The path to the root of the directory tree to remove. |
Remove trailing file separators from a file path.
| path | The path. |
Rename a file.
| oldName | The file to rename. | |
| newName | The new name for the file. |
| bool resolveSymLink | ( | String & | path | ) | throw () [static] |
Resolve a symbolic link.
| path | The path to the symbolic link. On return, the canonical path to the file to which the link points. |
| int64_t roundSizeToBlockSize | ( | const int64_t & | fileSize, | |
| size_t | blockSize | |||
| ) | [static] |
Round a file size to the next higher multiple of the given block size.
This method may be used to determine the actual amount of space that a file occupies on disk.
| fileSize | The file size. | |
| blockSize | The block size. |
| int64_t seek | ( | int64_t | offset, | |
| SeekMode | mode = SeekAbsolute | |||
| ) | throw (IOException) [virtual, inherited] |
Reposition the seek pointer in the stream.
| offset | The new offset. | |
| mode | The seek mode. |
| IOException | If the stream does not support seeking, or if some other I/O error occurred. |
| void setCreationMask | ( | const Permissions & | perm | ) | throw () [static] |
Set the file creation mask for the current process.
This function is POSIX-specific; it has no effect on Windows.
| perm | The permissions that will be turned off on newly created files. |
| bool setPermissions | ( | const String & | path, | |
| const Permissions & | perm | |||
| ) | throw () [static] |
Set the permissions on a file.
| path | The file. | |
| perm | The Permissions to set. |
| bool setPermissions | ( | const Permissions & | perm | ) | throw () |
Set the file permissions.
| perm | The Permissions to set. |
| void setTimeout | ( | timespan_ms_t | timeout | ) | throw (IOException) [virtual, inherited] |
Set the stream I/O timeout, in milliseconds.
A timeout of 0 indicates no timeout, and a timeout of -1 indicates infinite timeout (blocking I/O).
Reimplemented in SerialPort, and StreamSocket.
| int64_t tell | ( | ) | throw (IOException) [virtual, inherited] |
Get the current (absolute) offset of the seek pointer.
| IOException | If the stream does not support seeking, or if some other I/O error occurred. |
| bool touch | ( | const String & | path | ) | throw () [static] |
Touch a file.
The file's last-accessed timestamp is updated if the file exists; otherwise the file is created as an empty file.
| path | The path to the file. |
| bool touch | ( | ) | throw () |
Touch the file.
The file's last-accessed timestamp is updated if the file exists; otherwise the file is created as an empty file.
| void truncate | ( | uint64_t | size = 0 |
) | throw (IOException) |
Truncate the file to a given size.
On return, the file seek pointer will be at the end of the file.
| size | The new size of the file, which must be less than or equal to the file's current size. Truncating a file to extend its size produces different results on POSIX vs. Windows systems, and thus is not supported. |
| IOException | If the operation fails, or if the specified size is greater than the file's current size. |
| bool unlockRange | ( | uint64_t | start, | |
| uint64_t | length | |||
| ) | throw () |
Unlock a range of bytes in the file.
The range must match a range that was previously locked with lockRange().
| start | The start offset of the range to unlock. | |
| length | The length of the range to unlock. |
| size_t write | ( | const MemoryBlock * | vec, | |
| uint_t | count | |||
| ) | throw (IOException) [virtual, inherited] |
Write data to the stream from a series of I/O buffers.
This operation is known as "vector write" or "gather write." The buffers are written in order. On systems that support it, the operation is performed with a single system call.
| vec | An array of buffers to write. | |
| count | The number of buffers in the array. |
| IOException | If an I/O error occurred. |
Reimplemented in StreamSocket.
| size_t write | ( | const byte_t * | buffer, | |
| size_t | buflen | |||
| ) | throw (IOException) [virtual, inherited] |
Write data to the stream from a raw buffer, until either the entire buffer is written or an error or timeout occurs.
| buffer | A pointer to the buffer. | |
| buflen | The number of bytes to write. |
| IOException | If an I/O error occurred. |
Reimplemented in StreamSocket.
| size_t write | ( | Buffer< T > & | buffer, | |
| size_t & | partial | |||
| ) | throw (IOException) [inline, inherited] |
Write data to the stream from a Buffer of arbitrary type.
If sizeof(T) is greater than 1 byte, then there can be no guarantee that the number of bytes written before a timeout or error occurs will be evenly divisible by sizeof(T). If the final element was partially written, the number of bytes of the element that were written will be stored in partial; this value should be passed unmodified to the next invocation of this method to continue writing from the appropriate offset within the partially-written element.
| buffer | The buffer to write. | |
| partial | The number of bytes remaining to write for a partially-written element; on return, the number of bytes written of a partially-written element, or 0 if the last element was written completely. Should be set to 0 prior to the first call to this method for a fresh buffer. |
| IOException | If an I/O error occurred. |
| size_t write | ( | CharBuffer & | buffer | ) | throw (IOException) [virtual, inherited] |
Write data to the stream from a CharBuffer.
| buffer | The buffer to write. |
| IOException | If an I/O error occurred. |
Reimplemented in StreamSocket.
| size_t write | ( | ByteBuffer & | buffer | ) | throw (IOException) [virtual, inherited] |
Write data to the stream from a ByteBuffer.
| buffer | The buffer to write. |
| IOException | If an I/O error occurred. |
Reimplemented in StreamSocket.
| size_t write | ( | ByteBuffer & | buffer, | |
| int64_t | offset, | |||
| AsyncIOTask & | task | |||
| ) | throw (IOException) [inherited] |
Write data asynchronously to the stream from a Buffer.
| buffer | The Buffer to write. This object must not be destroyed before the asynchronous I/O operation is completed or cancelled. | |
| offset | The file offset to write to. | |
| task | The async I/O control block for monitoring the operation. |
| IOException | If an I/O error occurred. |
Reimplemented in StreamSocket.
| size_t write | ( | const byte_t * | buffer, | |
| size_t | buflen, | |||
| int64_t | offset, | |||
| AsyncIOTask & | task | |||
| ) | throw (IOException) [inherited] |
Write data asynchronously to the stream from a raw buffer.
| buffer | The buffer to write. | |
| buflen | The number of bytes to write. | |
| offset | The file offset to write to. | |
| task | The async I/O control block for monitoring the operation. |
| IOException | If an I/O error occurred. |
Reimplemented in StreamSocket.
| size_t writeFully | ( | const byte_t * | buffer, | |
| size_t | buflen | |||
| ) | throw (IOException) [virtual, inherited] |
Write data to the stream from a raw buffer.
| buffer | A pointer to the buffer. | |
| buflen | The number of bytes to write. |
| IOException | If an I/O error occurred. |
| size_t writeFully | ( | Buffer< T > & | buffer, | |
| size_t & | partial | |||
| ) | throw (IOException) [inline, inherited] |
Write data to the stream from a Buffer of arbitrary type, until either the entire buffer is written or an error or timeout occurs.
If sizeof(T) is greater than 1 byte, then there can be no guarantee that the number of bytes written before a timeout or error occurs will be evenly divisible by sizeof(T). If the final element was partially written, the number of bytes of the element that were written will be stored in partial; this value should be passed unmodified to the next invocation of this method to continue writing from the appropriate offset within the partially-written element.
| buffer | The buffer to write. | |
| partial | The number of bytes remaining to write for a partially-written element; on return, the number of bytes written of a partially-written element, or 0 if the last element was written completely. Should be set to 0 prior to the first call to this method for a fresh buffer. |
| IOException | If an I/O error occurred. |
| size_t writeFully | ( | CharBuffer & | buffer | ) | throw (IOException) [virtual, inherited] |
Write data to the stream from a CharBuffer, until either the entire buffer is written or an error or timeout occurs.
| buffer | The buffer to write. |
| IOException | If an I/O error occurred. |
| size_t writeFully | ( | ByteBuffer & | buffer | ) | throw (IOException) [virtual, inherited] |
Write data to the stream from a ByteBuffer, until either the entire buffer is written or an error or timeout occurs.
| buffer | The buffer to write. |
| IOException | If and I/O error occurred. |
const char * eol = EOL [static] |
The host system's end-of-line character sequence.
const uint_t MAX_IOBLOCK_COUNT = 16 [static, inherited] |
The maximum number of I/O buffers that can be passed to the vector I/O methods.
const char separator = FS [static] |
The host system's file separator character.
const char separatorString = { File::separator, NUL } [static] |
The host system's file separator character, as a string.
const char validSeparators [static] |
{ File::separator,
NUL }
A string containing all valid file separator characters for the host system.
On Windows, this string includes both `/' and '\', while on all other systems it is equivalent to File::separator.
1.6.3