Pyro higlevel API
|
Classes | |
class | Private |
Public Types | |
enum | { DEFAULT_BUFFER_SIZE =32768 } |
Public Member Functions | |
File () | |
Default constructor. More... | |
File (const String &cPath, int nOpenMode=O_RDONLY) | |
Construct a file from a regular path. More... | |
File (const Directory &cDir, const String &cName, int nOpenMode=O_RDONLY) | |
Open a file addressed as a name inside a specified directory. More... | |
File (const FileReference &cRef, int nOpenMode=O_RDONLY) | |
Open a file referred to by a os::FileReference. More... | |
File (const FSNode &cNode) | |
Construct a file from a FSNode. More... | |
File (int nFD) | |
Construct a file object from a open filedescriptor. More... | |
File (const File &cFile) | |
Copy constructor. More... | |
virtual | ~File () |
virtual status_t | FDChanged (int nNewFD, const struct stat &sStat) |
virtual off_t | GetSize (bool bUpdateCache=true) const |
virtual ssize_t | Read (void *pBuffer, ssize_t nSize) |
virtual ssize_t | Write (const void *pBuffer, ssize_t nSize) |
virtual ssize_t | ReadPos (off_t nPos, void *pBuffer, ssize_t nSize) |
virtual ssize_t | WritePos (off_t nPos, const void *pBuffer, ssize_t nSize) |
virtual off_t | Seek (off_t nPos, int nMode) |
Move the file pointer. More... | |
status_t | SetBufferSize (int nSize) |
Set the size of the files caching buffer. More... | |
int | GetBufferSize () const |
Obtain the files buffer size. More... | |
status_t | Flush () |
Write unwritten data to the underlying file. More... | |
Public Member Functions inherited from os::SeekableIO | |
virtual | ~SeekableIO () |
Public Member Functions inherited from os::StreamableIO | |
virtual | ~StreamableIO () |
Public Member Functions inherited from os::FSNode | |
FSNode () | |
Default contructor. More... | |
FSNode (const String &cPath, int nOpenMode=O_RDONLY) | |
Construct a FSNode from a file path. More... | |
FSNode (const Directory &cDir, const String &cName, int nOpenMode=O_RDONLY) | |
Construct a FSNode from directory and a name inside that directory. More... | |
FSNode (const FileReference &cRef, int nOpenMode=O_RDONLY) | |
Construct a FSNode from a file reference. More... | |
FSNode (int nFD) | |
Construct a FSNode from a file descriptor. More... | |
FSNode (const FSNode &cNode) | |
Copy contructor. More... | |
virtual | ~FSNode () |
Destructor. More... | |
virtual status_t | SetTo (const String &cPath, int nOpenMode=O_RDONLY) |
Open a node using a path. More... | |
virtual status_t | SetTo (const Directory &cDir, const String &cPath, int nOpenMode=O_RDONLY) |
Open a node using a dir/path pair. More... | |
virtual status_t | SetTo (const FileReference &cRef, int nOpenMode=O_RDONLY) |
Open the node referred to by the given os::FileReference. More... | |
virtual status_t | SetTo (int nFD) |
Make the FSNode represent an already open file. More... | |
virtual status_t | SetTo (const FSNode &cNode) |
Copy another FSNode. More... | |
virtual void | Unset () |
Reset the FSNode. More... | |
virtual bool | IsValid () const |
Check if the node has been properly initialized. More... | |
virtual status_t | GetStat (struct stat *psStat, bool bUpdateCache=true) const |
virtual ino_t | GetInode () const |
virtual dev_t | GetDev () const |
virtual int | GetMode (bool bUpdateCache=false) const |
virtual time_t | GetCTime (bool bUpdateCache=true) const |
virtual time_t | GetMTime (bool bUpdateCache=true) const |
virtual time_t | GetATime (bool bUpdateCache=true) const |
bool | IsDir () const |
bool | IsLink () const |
bool | IsFile () const |
bool | IsCharDev () const |
bool | IsBlockDev () const |
bool | IsFIFO () const |
virtual status_t | GetNextAttrName (String *pcName) |
Read the node's attribute directory. More... | |
virtual status_t | RewindAttrdir () |
Reset the attribute directory iterator. More... | |
virtual ssize_t | WriteAttr (const String &cAttrName, int nFlags, int nType, const void *pBuffer, off_t nPos, size_t nLen) |
Add/update an attribute. More... | |
virtual ssize_t | ReadAttr (const String &cAttrName, int nType, void *pBuffer, off_t nPos, size_t nLen) |
Read the data held by an attribute. More... | |
virtual status_t | RemoveAttr (const String &cName) |
Remove an attribute from an FS node. More... | |
virtual status_t | StatAttr (const String &cName, struct::attr_info *psBuffer) |
Get extended info about an attribute. More... | |
virtual int | GetFileDescriptor () const |
File::File | ( | ) |
File::File | ( | const String & | cPath, |
int | nOpenMode = O_RDONLY |
||
) |
cPath
. The node must be a regular file or a symlink pointing at a regular file. Anything else will cause and errno_exception(EINVAL) exception to be thrown.cPath | The file to open. The path can eigther be absolute (starting with "/") or relative to the current working directory. |
nOpenMode | Flags controling how the file should be opened. The value should be one of the O_RDONLY, O_WRONLY, or O_RDWR. In addition the following flags can be bitwise or'd in to further control the operation: - O_TRUNC trunate the size to 0. - O_APPEND automatically move the file-pointer to the end of the file before each write (only valid for files) - O_NONBLOCK open the file in non-blocking mode. This is only relevant for named pipes and PTY's. - O_NOCTTY Don't make the file controlling TTY even if \p cPath points to a PTY. |
References os::FSNode::GetMode().
cDir | The directory to use as a base for cPath |
cPath | Path relative to cPath . |
nOpenMode | Flags controlling how to open the file. See File( const std::string& cPath, int nOpenMode ) for a full description. |
References os::FSNode::GetMode().
File::File | ( | const FileReference & | cRef, |
int | nOpenMode = O_RDONLY |
||
) |
cRef | Reference to the file to open. |
nOpenMode | Flags controlling how to open the file. See File( const std::string& cPath, int nOpenMode ) for a full description. |
References os::FSNode::GetMode().
File::File | ( | const FSNode & | cNode | ) |
cNode | The FSNode to downcast. |
References os::FSNode::GetMode().
File::File | ( | int | nFD | ) |
\return |
References os::FSNode::GetMode().
File::File | ( | const File & | cFile | ) |
cFile
. The copy and original will have their own file pointers and they will have their own attribute directory iterators (see note). cFile | The file object to copy. |
References os::File::Private::m_nBufferSize, and os::File::Private::m_nPosition.
|
virtual |
References Flush(), os::File::Private::m_bDirty, and os::File::Private::m_pBuffer.
|
virtual |
Reimplemented from os::FSNode.
References Flush(), os::FSNode::IsValid(), os::File::Private::m_bDirty, and os::File::Private::m_nValidBufSize.
status_t File::Flush | ( | void | ) |
References os::FSNode::GetFileDescriptor(), os::File::Private::m_bDirty, os::File::Private::m_cMutex, os::File::Private::m_nBufPos, os::File::Private::m_nValidBufSize, and os::File::Private::m_pBuffer.
Referenced by FDChanged(), os::RegistrarManager::RegisterTypeIconFromRes(), SetBufferSize(), WritePos(), and ~File().
int File::GetBufferSize | ( | ) | const |
References os::File::Private::m_nBufferSize.
|
virtual |
Reimplemented from os::FSNode.
References os::FSNode::GetSize(), os::File::Private::m_cMutex, os::File::Private::m_nBufPos, and os::File::Private::m_nValidBufSize.
Referenced by Seek().
|
virtual |
Implements os::StreamableIO.
References os::File::Private::m_cMutex, os::File::Private::m_nPosition, and ReadPos().
|
virtual |
Implements os::SeekableIO.
References os::FSNode::GetFileDescriptor(), os::File::Private::m_cMutex, os::File::Private::m_nBufferSize, os::File::Private::m_nBufPos, os::File::Private::m_nValidBufSize, and os::File::Private::m_pBuffer.
Referenced by Read().
|
virtual |
\return |
Implements os::SeekableIO.
References GetSize(), os::File::Private::m_cMutex, and os::File::Private::m_nPosition.
status_t File::SetBufferSize | ( | int | nBufferSize | ) |
If you read/write large chunks of data at the time the buffer might impose more overhead than gain and it could be a good idea to disable the buffering entirely by setting the buffer size to 0. When for example streaming video the amount of data read are probably going to be much larger than the buffer anyway and each byte is only read once by the application and if the application read the file in reasonably sized chunks the extra copy imposed by reading the data into the internal buffer and then copy it to the callers buffer will only decrease the performance.
nBufferSize | The buffer size in bytes. If the size is set to 0 the file will be unbuffered and each call to Read()/Write() and ReadPos()/WritePos() will translate directly to kernel calls. |
References Flush(), os::File::Private::m_bDirty, os::File::Private::m_cMutex, os::File::Private::m_nBufferSize, os::File::Private::m_nValidBufSize, and os::File::Private::m_pBuffer.
|
virtual |
Implements os::StreamableIO.
References os::File::Private::m_cMutex, os::File::Private::m_nPosition, and WritePos().
Referenced by os::RegistrarManager::RegisterTypeIconFromRes().
|
virtual |
Implements os::SeekableIO.
References Flush(), os::FSNode::GetFileDescriptor(), os::File::Private::m_bDirty, os::File::Private::m_cMutex, os::File::Private::m_nBufferSize, os::File::Private::m_nBufPos, os::File::Private::m_nValidBufSize, and os::File::Private::m_pBuffer.
Referenced by Write().