OW_NAMESPACE::File Class Reference

The purpose of the File class is to provide an abstraction layer over the platform dependant functionality related to a file. More...

#include <OW_File.hpp>

List of all members.

Public Types

typedef FileHandle File::* safe_bool

Public Member Functions

 File ()
 Create a NULL File object.
 File (const File &x)
 Copy constructor.
 ~File ()
Fileoperator= (const File &x)
 Assignment operator.
void swap (File &x)
size_t read (void *bfr, size_t numberOfBytes, off_t offset=-1L) const
 Read from the underlying file.
size_t write (const void *bfr, size_t numberOfBytes, off_t offset=-1L)
 Write to the underlying file.
int seek (off_t offset, int whence) const
 Seek to a given offset within the file.
off_t tell () const
void rewind () const
 Position the file pointer to the beginning of the file.
int close ()
 Close the underlying file object.
int flush ()
 Flush any buffered data to the file.
int getLock ()
 Acquire a kernel lock on the file.
int tryLock ()
 Acquire a kernel lock on the file.
int unlock ()
 Release a lock on the file.
 operator safe_bool () const
bool operator! () const
bool operator== (const File &rhs)
 Equality operator.
 File (FileHandle hdl)

Private Attributes

FileHandle m_hdl


Detailed Description

The purpose of the File class is to provide an abstraction layer over the platform dependant functionality related to a file.

Definition at line 50 of file OW_File.hpp.


Member Typedef Documentation

typedef FileHandle File::* OW_NAMESPACE::File::safe_bool
 

Definition at line 190 of file OW_File.hpp.


Constructor & Destructor Documentation

OW_NAMESPACE::File::File  )  [inline]
 

Create a NULL File object.

Definition at line 56 of file OW_File.hpp.

OW_NAMESPACE::File::File const File x  ) 
 

Copy constructor.

Parameters:
x The File object to copy.

Definition at line 129 of file OW_PosixFile.cpp.

OW_NAMESPACE::File::~File  )  [inline]
 

Definition at line 64 of file OW_File.hpp.

References OW_NAMESPACE::FileSystem::close().

OW_NAMESPACE::File::File FileHandle  hdl  )  [inline]
 

Definition at line 208 of file OW_File.hpp.


Member Function Documentation

int OW_NAMESPACE::File::close  )  [inline]
 

Close the underlying file object.

Returns:
0 on success. Otherwise -1.

Definition at line 142 of file OW_File.hpp.

References OW_NAMESPACE::FileSystem::close(), m_hdl, and OW_INVALID_FILEHANDLE.

Referenced by OW_NAMESPACE::HDB::checkFile(), OW_NAMESPACE::AssocDb::checkFile(), OW_NAMESPACE::ServerSocketImpl::close(), OW_NAMESPACE::HDB::close(), OW_NAMESPACE::HDB::createFile(), OW_NAMESPACE::AssocDb::createFile(), OW_NAMESPACE::TempFileEnumerationImplBase::readSize(), OW_NAMESPACE::AssocDbHandle::AssocDbHandleData::~AssocDbHandleData(), and OW_NAMESPACE::HDBHandle::HDBHandleData::~HDBHandleData().

int OW_NAMESPACE::File::flush  )  [inline]
 

Flush any buffered data to the file.

Returns:
0 on success. Otherwise -1.

Definition at line 156 of file OW_File.hpp.

References OW_NAMESPACE::FileSystem::flush(), and m_hdl.

int OW_NAMESPACE::File::getLock  ) 
 

Acquire a kernel lock on the file.

This call may block. The lock may be released by calling unlock(). The lock will also be released when the the file is closed or when locking application exits. This is only an advisory lock and will not prevent non-coordinated access to the file.

Returns:
0 on sucess. On error, -1 is returned, and errno is set appropriately. errno may be one of: EBADF, EDEADLK, EINVAL, ENOLCK

Definition at line 150 of file OW_PosixFile.cpp.

References OW_NAMESPACE::doLock(), and m_hdl.

OW_NAMESPACE::File::operator safe_bool  )  const [inline]
 

Returns:
true if this is a valid File object.

Definition at line 194 of file OW_File.hpp.

References m_hdl, m_hdl, and OW_INVALID_FILEHANDLE.

bool OW_NAMESPACE::File::operator!  )  const [inline]
 

Definition at line 196 of file OW_File.hpp.

References m_hdl, and OW_INVALID_FILEHANDLE.

File& OW_NAMESPACE::File::operator= const File x  )  [inline]
 

Assignment operator.

Parameters:
x The File object to copy.
Returns:
A reference to this File object.

Definition at line 73 of file OW_File.hpp.

bool OW_NAMESPACE::File::operator== const File rhs  )  [inline]
 

Equality operator.

Parameters:
rhs The File object to compare this object to.
Returns:
true if this File represents the same file as rhs.

Definition at line 203 of file OW_File.hpp.

References m_hdl, and m_hdl.

size_t OW_NAMESPACE::File::read void *  bfr,
size_t  numberOfBytes,
off_t  offset = -1L
const [inline]
 

Read from the underlying file.

Parameters:
bfr The location where the read operation will place what is read.
numberOfBytes The number of bytes to read.
offset The offset to seek to in the file before the read operation is done. -1 will use the current offset.
Returns:
The number of bytes read. If EOF or an error occurs, a short count or zero is returned.

Definition at line 92 of file OW_File.hpp.

References m_hdl, and OW_NAMESPACE::BinarySerialization::read().

Referenced by OW_NAMESPACE::HDB::checkFile(), OW_NAMESPACE::AssocDb::checkFile(), OW_NAMESPACE::dlSharedLibrary::isFakeLibrary(), OW_NAMESPACE::HDBNode::read(), OW_NAMESPACE::HDB::readBlock(), OW_NAMESPACE::readRecHeader(), OW_NAMESPACE::TempFileEnumerationImplBase::readSize(), and OW_NAMESPACE::HDBNode::removeBlock().

void OW_NAMESPACE::File::rewind  )  const [inline]
 

Position the file pointer to the beginning of the file.

Definition at line 134 of file OW_File.hpp.

References m_hdl, and OW_NAMESPACE::FileSystem::rewind().

int OW_NAMESPACE::File::seek off_t  offset,
int  whence
const [inline]
 

Seek to a given offset within the file.

Parameters:
offset The offset to seek to relative to the whence parm.
whence Can be one of the follwing values: SEEK_SET - Seek relative to the beginning of the file. SEEK_CUR - Seek relative to the current position. SEEK_END - Seek relative to the end of the file (bwd).
Returns:
The the current location in the file relative to the beginning of the file on success. Other -1.

Definition at line 119 of file OW_File.hpp.

References m_hdl, and OW_NAMESPACE::FileSystem::seek().

Referenced by OW_NAMESPACE::TempFileEnumerationImplBase::readSize().

void OW_NAMESPACE::File::swap File x  )  [inline]
 

Definition at line 78 of file OW_File.hpp.

References m_hdl, m_hdl, and OW_NAMESPACE::swap().

off_t OW_NAMESPACE::File::tell  )  const [inline]
 

Returns:
The current position in the file relative to the beginning of the file on success. Otherwise -1.

Definition at line 127 of file OW_File.hpp.

References m_hdl, and OW_NAMESPACE::FileSystem::tell().

int OW_NAMESPACE::File::tryLock  ) 
 

Acquire a kernel lock on the file.

This call won't block. The lock may be released by calling unlock() The lock will also be released when the locking application exits. This is only an advisory lock and will not prevent non-coordinated access to the file.

Returns:
0 on sucess. On error, -1 is returned, and errno is set appropriately. errno may be one of: EACCES, EAGAIN, EBADF, EDEADLK, EINVAL, ENOLCK. EACCES or EAGAIN signifies the file is already locked.

Definition at line 156 of file OW_PosixFile.cpp.

References OW_NAMESPACE::doLock(), and m_hdl.

Referenced by OW_NAMESPACE::ServerSocketImpl::doListen(), OW_NAMESPACE::HDB::open(), and OW_NAMESPACE::PidFile::writePid().

int OW_NAMESPACE::File::unlock  ) 
 

Release a lock on the file.

This call will not block.

Returns:
0 on sucess. On error, -1 is returned, and errno is set appropriately. errno may be one of: EAGAIN, EBADF, EDEADLK, EINVAL, ENOLCK

Definition at line 162 of file OW_PosixFile.cpp.

References OW_NAMESPACE::doLock(), and m_hdl.

Referenced by OW_NAMESPACE::ServerSocketImpl::close(), and OW_NAMESPACE::HDB::close().

size_t OW_NAMESPACE::File::write const void *  bfr,
size_t  numberOfBytes,
off_t  offset = -1L
[inline]
 

Write to the underlying file.

Parameters:
bfr The locaction to get the contents to write.
numberOfBytes The number of bytes to write.
offset The offset to seek to in the file before the write operation is done. -1 will use the current offset.
Returns:
The number of bytes written. If an error occurs, a short count or zero is returned.

Definition at line 105 of file OW_File.hpp.

References m_hdl, and OW_NAMESPACE::BinarySerialization::write().

Referenced by OW_NAMESPACE::AssocDb::addEntry(), OW_NAMESPACE::AssocDb::addToFreeList(), OW_NAMESPACE::LocalAuthenticationCommon::createFile(), OW_NAMESPACE::HDB::createFile(), OW_NAMESPACE::AssocDb::createFile(), OW_NAMESPACE::HDB::setOffsets(), OW_NAMESPACE::HDBNode::write(), OW_NAMESPACE::HDB::writeBlock(), and OW_NAMESPACE::writeRecHeader().


Member Data Documentation

FileHandle OW_NAMESPACE::File::m_hdl [private]
 

Definition at line 214 of file OW_File.hpp.

Referenced by getLock(), operator safe_bool(), operator==(), swap(), tryLock(), and unlock().


The documentation for this class was generated from the following files:
Generated on Thu Feb 9 09:13:47 2006 for openwbem by  doxygen 1.4.6