class File

A stream file class. More...

Full nameTelEngine::File
Definition#include <yateclass.h>
InheritsTelEngine::Stream [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Static Methods

Protected Methods

Protected Members


Detailed Description

Class to encapsulate a system dependent file in a system independent abstraction

 File ()

File

Default constructor, creates a closed file

explicit  File (HANDLE handle)

File

Constructor from an existing handle

Parameters:
handleOperating system handle to an open file

 ~File ()

~File

[virtual]

Destructor, closes the file

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)

openPath

[virtual]

Opens a file from the filesystem pathname

Parameters:
nameName of the file according to the operating system's conventions
canWriteOpen the file for writing
canReadOpen the file for reading
createCreate the file if it doesn't exist
appendSet the write pointer at the end of an existing file
binaryOpen the file in binary mode if applicable
pubReadableIf the file is created make it public readable
pubWritableIf the file is created make it public writable

Returns: True if the file was successfully opened

bool  terminate ()

terminate

[virtual]

Closes the file handle

Returns: True if the file was (already) closed, false if an error occured

Reimplemented from Stream.

void  attach (HANDLE handle)

attach

Attach an existing handle to the file, closes any existing first

Parameters:
handleOperating system handle to an open file

HANDLE  detach ()

detach

Detaches the object from the file handle

Returns: The handle previously owned by this object

inline HANDLE  handle ()

handle

[const]

Get the operating system handle to the file

Returns: File handle

bool  canRetry ()

canRetry

[const virtual]

Check if the last error code indicates a retryable condition

Returns: True if error was temporary and operation should be retried

Reimplemented from Stream.

bool  valid ()

valid

[const virtual]

Check if this file is valid

Returns: True if the file is valid, false if it's invalid or closed

Reimplemented from Stream.

HANDLE  invalidHandle ()

invalidHandle

[static]

Get the operating system specific handle value for an invalid file

Returns: Handle value for an invalid file

bool  setBlocking (bool block = true)

setBlocking

[virtual]

Set the blocking or non-blocking operation mode of the file

Parameters:
blockTrue if I/O operations should block, false for non-blocking

Returns: True if operation was successfull, false if an error occured

Reimplemented from Stream.

int64_t  length ()

length

[virtual]

Find the length of the file if it has one

Returns: Length of the file or zero if length is not defined

Reimplemented from Stream.

int64_t  seek (SeekPos pos, int64_t offset = 0)

seek

[virtual]

Set the file read/write pointer

Parameters:
posThe seek start as enumeration
offsetThe number of bytes to move the pointer from starting position

Returns: The new position of the file read/write pointer. Negative on failure

Reimplemented from Stream.

int  writeData (const void* buffer, int length)

writeData

[virtual]

Write data to an open file

Parameters:
bufferBuffer for data transfer
lengthLength of the buffer

Returns: Number of bytes transferred, negative if an error occurred

Reimplemented from Stream.

int  readData (void* buffer, int length)

readData

[virtual]

Read data from an open file

Parameters:
bufferBuffer for data transfer
lengthLength of the buffer

Returns: Number of bytes transferred, negative if an error occurred

Reimplemented from Stream.

bool  getFileTime (unsigned int& secEpoch)

getFileTime

Retrieve the file's modification time (the file must be already opened)

Parameters:
secEpochFile creation time (seconds since Epoch)

Returns: True on success

bool  md5 (String& buffer)

md5

[virtual]

Build the MD5 hex digest of a file. The file must be opened for read access. This method will move the file pointer

Parameters:
bufferDestination buffer

Returns: True on success

bool  setFileTime (const char* name, unsigned int secEpoch, int* error = 0)

setFileTime

[static]

Set a file's modification time.

Parameters:
namePath and name of the file
secEpochFile modification time (seconds since Epoch)
errorOptional pointer to error code to be filled on failure

Returns: True on success

bool  getFileTime (const char* name, unsigned int& secEpoch, int* error = 0)

getFileTime

[static]

Retrieve a file's modification time

Parameters:
namePath and name of the file
secEpochFile modification time (seconds since Epoch)
errorOptional pointer to error code to be filled on failure

Returns: True on success

bool  exists (const char* name, int* error = 0)

exists

[static]

Check if a file exists

Parameters:
nameThe file to check
errorOptional pointer to error code to be filled on failure

Returns: True if the file exists

bool  rename (const char* oldFile, const char* newFile, int* error = 0)

rename

[static]

Rename (move) a file (or directory) entry from the filesystem

Parameters:
oldFilePath and name of the file to rename
newFileThe new path and name of the file
errorOptional pointer to error code to be filled on failure

Returns: True if the file was successfully renamed (moved)

bool  remove (const char* name, int* error = 0)

remove

[static]

Deletes a file entry from the filesystem

Parameters:
nameAbsolute path and name of the file to delete
errorOptional pointer to error code to be filled on failure

Returns: True if the file was successfully deleted

bool  md5 (const char* name, String& buffer, int* error = 0)

md5

[static]

Build the MD5 hex digest of a file.

Parameters:
nameThe file to build MD5 from
bufferDestination buffer
errorOptional pointer to error code to be filled on failure

Returns: True on success

bool  mkDir (const char* path, int* error = 0)

mkDir

[static]

Create a folder (directory). It only creates the last directory in the path

Parameters:
pathThe folder path
errorOptional pointer to error code to be filled on failure

Returns: True on success

bool  rmDir (const char* path, int* error = 0)

rmDir

[static]

Remove an empty folder (directory)

Parameters:
pathThe folder path
errorOptional pointer to error code to be filled on failure

Returns: True on success

bool  listDirectory (const char* path, ObjList* dirs, ObjList* files, int* error = 0)

listDirectory

[static]

Enumerate a folder (directory) content. Fill the given lists with children item names

Parameters:
pathThe folder path
dirsList to be filled with child directories. It can be NULL if not requested
filesList to be filled with child files. It can be NULL if not requested
errorOptional pointer to error code to be filled on failure

Returns: True on success

bool  createPipe (File& reader, File& writer)

createPipe

[static]

Create a pair of unidirectionally pipe connected streams

Parameters:
readerReference to a File that becomes the reading side of the pipe
writerReference to a File that becomes the writing side of the pipe

Returns: True is the pipe was created successfully

void  copyError ()

copyError

[protected]

Copy the last error code from the operating system

HANDLE m_handle

m_handle

[protected]


Generated by: paulc on bussard on Fri Dec 21 16:28:34 2012, using kdoc 2.0a54.