|
Yate
|
A stream file class. More...
#include <yateclass.h>
Public Member Functions | |
| File () | |
| File (HANDLE handle) | |
| virtual | ~File () |
| virtual bool | openPath (const char *name, bool canWrite=false, bool canRead=true, bool create=false, bool append=false, bool binary=false, bool pubReadable=false, bool pubWritable=false) |
| virtual bool | terminate () |
| void | attach (HANDLE handle) |
| HANDLE | detach () |
| HANDLE | handle () const |
| virtual bool | canRetry () const |
| virtual bool | valid () const |
| virtual bool | setBlocking (bool block=true) |
| virtual int64_t | length () |
| virtual int64_t | seek (SeekPos pos, int64_t offset=0) |
| virtual int | writeData (const void *buffer, int length) |
| virtual int | readData (void *buffer, int length) |
| bool | getFileTime (unsigned int &secEpoch) |
| virtual bool | md5 (String &buffer) |
| Public Member Functions inherited from Stream | |
| virtual | ~Stream () |
| int | error () const |
| virtual bool | inProgress () const |
| int | writeData (const char *str) |
| int | writeData (const String &str) |
| int | writeData (const DataBlock &buf) |
| int64_t | seek (int64_t offset) |
Static Public Member Functions | |
| static HANDLE | invalidHandle () |
| static bool | setFileTime (const char *name, unsigned int secEpoch, int *error=0) |
| static bool | getFileTime (const char *name, unsigned int &secEpoch, int *error=0) |
| static bool | exists (const char *name, int *error=0) |
| static bool | rename (const char *oldFile, const char *newFile, int *error=0) |
| static bool | remove (const char *name, int *error=0) |
| static bool | md5 (const char *name, String &buffer, int *error=0) |
| static bool | mkDir (const char *path, int *error=0, int mode=-1) |
| static bool | rmDir (const char *path, int *error=0) |
| static bool | listDirectory (const char *path, ObjList *dirs, ObjList *files, int *error=0) |
| static bool | createPipe (File &reader, File &writer) |
| Static Public Member Functions inherited from Stream | |
| static bool | allocPipe (Stream *&reader, Stream *&writer) |
| static bool | allocPair (Stream *&str1, Stream *&str2) |
| static bool | supportsPipes () |
| static bool | supportsPairs () |
Protected Member Functions | |
| void | copyError () |
| Protected Member Functions inherited from Stream | |
| Stream () | |
| void | clearError () |
Protected Attributes | |
| HANDLE | m_handle |
| Protected Attributes inherited from Stream | |
| int | m_error |
Additional Inherited Members | |
| Public Types inherited from Stream | |
| enum | SeekPos { SeekBegin , SeekEnd , SeekCurrent } |
A stream file class.
Class to encapsulate a system dependent file in a system independent abstraction
| File | ( | ) |
Default constructor, creates a closed file
Referenced by createPipe().
|
explicit |
|
virtual |
Destructor, closes the file
| void attach | ( | HANDLE | handle | ) |
|
virtual |
Check if the last error code indicates a retryable condition
Reimplemented from Stream.
|
protected |
Copy the last error code from the operating system
| HANDLE detach | ( | ) |
Detaches the object from the file handle
|
static |
Check if a file exists
| name | The file to check |
| error | Optional pointer to error code to be filled on failure |
References Stream::error().
|
static |
Retrieve a file's modification time
| name | Path and name of the file |
| secEpoch | File modification time (seconds since Epoch) |
| error | Optional pointer to error code to be filled on failure |
References Stream::error().
| bool getFileTime | ( | unsigned int & | secEpoch | ) |
Retrieve the file's modification time (the file must be already opened)
| secEpoch | File creation time (seconds since Epoch) |
|
inline |
|
static |
Get the operating system specific handle value for an invalid file
|
virtual |
Find the length of the file if it has one
Reimplemented from Stream.
Referenced by readData(), and writeData().
Enumerate a folder (directory) content. Fill the given lists with children item names
| path | The folder path |
| dirs | List to be filled with child directories. It can be NULL if not requested |
| files | List to be filled with child files. It can be NULL if not requested |
| error | Optional pointer to error code to be filled on failure |
References Stream::error().
|
static |
Build the MD5 hex digest of a file.
| name | The file to build MD5 from |
| buffer | Destination buffer |
| error | Optional pointer to error code to be filled on failure |
References Stream::error().
|
virtual |
Build the MD5 hex digest of a file. The file must be opened for read access. This method will move the file pointer
| buffer | Destination buffer |
|
static |
Create a folder (directory). It only creates the last directory in the path
| path | The folder path |
| error | Optional pointer to error code to be filled on failure |
| mode | Optional file mode, ignored on some platforms |
References Stream::error().
|
virtual |
Opens a file from the filesystem pathname
| name | Name of the file according to the operating system's conventions |
| canWrite | Open the file for writing |
| canRead | Open the file for reading |
| create | Create the file if it doesn't exist |
| append | Set the write pointer at the end of an existing file |
| binary | Open the file in binary mode if applicable |
| pubReadable | If the file is created make it public readable |
| pubWritable | If the file is created make it public writable |
|
virtual |
|
static |
Deletes a file entry from the filesystem
| name | Absolute path and name of the file to delete |
| error | Optional pointer to error code to be filled on failure |
References Stream::error().
|
static |
Rename (move) a file (or directory) entry from the filesystem
| oldFile | Path and name of the file to rename |
| newFile | The new path and name of the file |
| error | Optional pointer to error code to be filled on failure |
References Stream::error().
|
static |
Remove an empty folder (directory)
| path | The folder path |
| error | Optional pointer to error code to be filled on failure |
References Stream::error().
|
virtual |
Set the file read/write pointer
| pos | The seek start as enumeration |
| offset | The number of bytes to move the pointer from starting position |
Reimplemented from Stream.
|
virtual |
Set the blocking or non-blocking operation mode of the file
| block | True if I/O operations should block, false for non-blocking |
Reimplemented from Stream.
|
static |
Set a file's modification time.
| name | Path and name of the file |
| secEpoch | File modification time (seconds since Epoch) |
| error | Optional pointer to error code to be filled on failure |
References Stream::error().
|
virtual |
Closes the file handle
Implements Stream.
|
virtual |
Check if this file is valid
Implements Stream.
|
virtual |