OW_NAMESPACE::FileSystem Namespace Reference

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


Namespaces

namespace  Path

Functions

File openFile (const String &path)
 Open a file for read/write and return an File object that can be used for reading and writing.
File createFile (const String &path)
 Create the file for the given name.
File openOrCreateFile (const String &path)
 Opens or creates the file for the given name.
int changeFileOwner (const String &filename, const UserId &userId)
 Change the given file ownership.
bool exists (const String &path)
bool isExecutable (const String &path)
 Tests if a file is executable.
bool canRead (const String &path)
bool canWrite (const String &path)
bool isLink (const String &path)
 Tests if a file is a symbolic link.
bool isDirectory (const String &path)
bool changeDirectory (const String &path)
 Change to the given directory.
bool makeDirectory (const String &path, int mode=0777)
 Create a directory.
bool getFileSize (const String &path, off_t &size)
 Get the size of the file in bytes.
bool removeDirectory (const String &path)
 Remove the given directory.
bool removeFile (const String &path)
 Remove the given file.
bool getDirectoryContents (const String &path, StringArray &dirEntries)
 Get the names of the files (and directories) in the given directory.
bool renameFile (const String &oldFileName, const String &newFileName)
 Rename the given file to the new name.
size_t read (const FileHandle &hdl, void *bfr, size_t numberOfBytes, off_t offset=-1L)
 Read data from file.
size_t write (FileHandle &hdl, const void *bfr, size_t numberOfBytes, off_t offset=-1L)
 Write data to a file.
off_t seek (const FileHandle &hdl, off_t offset, int whence)
 Seek to a given offset within the file.
off_t tell (const FileHandle &hdl)
void rewind (const FileHandle &hdl)
 Position the file pointer associated with the given file handle to the beginning of the file.
int close (const FileHandle &hdl)
 Close file handle.
int flush (FileHandle &hdl)
 Flush any buffered data to the file if buffering supported.
void initRandomFile (const String &file)
 Create a file with random data.
String getFileContents (const String &filename)
 Read and return the contents of a text file.
StringArray getFileLines (const String &filename)
 Read and return the lines of a test file.
String readSymbolicLink (const String &path)
 Read the value of a symbolic link.


Detailed Description

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

Function Documentation

bool OW_NAMESPACE::FileSystem::canRead const String &  path  ) 
 

Returns:
true if the file exists and can be read

Definition at line 183 of file OW_PosixFileSystem.cpp.

References _ACCESS, and OW_NAMESPACE::String::c_str().

Referenced by OW_NAMESPACE::HTTPXMLCIMListener::HTTPXMLCIMListener(), OW_NAMESPACE::dlSharedLibrary::isFakeLibrary(), and OW_NAMESPACE::IndexImpl::open().

bool OW_NAMESPACE::FileSystem::canWrite const String &  path  ) 
 

Returns:
true if the file exists and can be written

Definition at line 189 of file OW_PosixFileSystem.cpp.

References _ACCESS, and OW_NAMESPACE::String::c_str().

Referenced by OW_NAMESPACE::IndexImpl::open(), and OW_NAMESPACE::CIMRepository2::open().

bool OW_NAMESPACE::FileSystem::changeDirectory const String &  path  ) 
 

Change to the given directory.

Parameters:
path The directory to change to
Returns:
true if the operation succeeds. Otherwise false.

Definition at line 228 of file OW_PosixFileSystem.cpp.

References _CHDIR, and OW_NAMESPACE::String::c_str().

int OW_NAMESPACE::FileSystem::changeFileOwner const String &  filename,
const UserId userId
 

Change the given file ownership.

Parameters:
filename The name of the file to change ownership on.
userId The user id to change ownership to
Returns:
0 on success. Otherwise -1

Definition at line 106 of file OW_PosixFileSystem.cpp.

References OW_NAMESPACE::String::c_str().

Referenced by OW_NAMESPACE::BinaryRequestHandler::writeFileName().

int OW_NAMESPACE::FileSystem::close const FileHandle hdl  ) 
 

Close file handle.

Parameters:
hdl The file handle to close.
Returns:
0 on success. Otherwise -1.

Definition at line 421 of file OW_PosixFileSystem.cpp.

Referenced by OW_NAMESPACE::File::close(), OW_NAMESPACE::closeFile(), OW_NAMESPACE::SocketBaseImpl::disconnect(), OW_NAMESPACE::NwIface::NwIface(), OW_NAMESPACE::Select::selectRWEpoll(), OW_NAMESPACE::PidFile::writePid(), and OW_NAMESPACE::File::~File().

File OW_NAMESPACE::FileSystem::createFile const String &  path  ) 
 

Create the file for the given name.

Parameters:
path The name of the file to create.
Returns:
On success an File object that can be used for reading and writing. Otherwise a NULL File object. If the file exists, a NULL File object will be returned.

Definition at line 133 of file OW_PosixFileSystem.cpp.

References OW_NAMESPACE::String::c_str().

Referenced by OW_NAMESPACE::HDB::createFile(), OW_NAMESPACE::AssocDb::createFile(), OW_NAMESPACE::generateNewCookieFile(), and processCreate().

bool OW_NAMESPACE::FileSystem::exists const String &  path  ) 
 

Returns:
true if the file exists (and false otherwise).

Definition at line 167 of file OW_PosixFileSystem.cpp.

References _ACCESS, and OW_NAMESPACE::String::c_str().

Referenced by OW_NAMESPACE::FileAppender::doProcessLogMessage(), OW_NAMESPACE::locateInPath(), and OW_NAMESPACE::CIMRepository2::open().

int OW_NAMESPACE::FileSystem::flush FileHandle hdl  ) 
 

Flush any buffered data to the file if buffering supported.

Parameters:
hdl The file handle to flush the buffer on.

Definition at line 431 of file OW_PosixFileSystem.cpp.

Referenced by OW_NAMESPACE::File::flush().

bool OW_NAMESPACE::FileSystem::getDirectoryContents const String &  path,
StringArray dirEntries
 

Get the names of the files (and directories) in the given directory.

Parameters:
path The name of the directory to get the contents of.
dirEntries The directory contents will be placed in this array.
Returns:
true if the operation succeeds. Otherwise false.

Definition at line 272 of file OW_PosixFileSystem.cpp.

References OW_NAMESPACE::String::endsWith(), and OW_FILENAME_SEPARATOR.

Referenced by OW_NAMESPACE::MOF::findMOF(), OW_NAMESPACE::ProviderIFCLoader::loadIFCs(), OW_NAMESPACE::PerlProviderIFC::loadNoIdProviders(), OW_NAMESPACE::NPIProviderIFC::loadNoIdProviders(), OW_NAMESPACE::CMPIProviderIFC::loadNoIdProviders(), OWBI1::BI1ProviderIFC::loadProviders(), OW_NAMESPACE::PerlProviderIFC::loadProviders(), and OW_NAMESPACE::CppProviderIFC::loadProviders().

String OW_NAMESPACE::FileSystem::getFileContents const String &  filename  ) 
 

Read and return the contents of a text file.

If the file contains a null character ('') then only previous data will be returned.

Parameters:
filename The name of the file to read
Exceptions:
FileSystemException if the file doesn't exist or reading fails for any reason.

Definition at line 489 of file OW_PosixFileSystem.cpp.

References OW_NAMESPACE::String::c_str(), OW_THROW, and OW_NAMESPACE::OStringStream::toString().

Referenced by getFileLines().

StringArray OW_NAMESPACE::FileSystem::getFileLines const String &  filename  ) 
 

Read and return the lines of a test file.

If the file contains a null character ('') then only previous data will be returned.

Parameters:
filename The name of the file to read
Exceptions:
FileSystemException if the file doesn't exist or reading fails for any reason.

Definition at line 502 of file OW_PosixFileSystem.cpp.

References getFileContents(), and OW_NAMESPACE::String::tokenize().

bool OW_NAMESPACE::FileSystem::getFileSize const String &  path,
off_t size
 

Get the size of the file in bytes.

Parameters:
path The name of the file to get the size for.
size Put the size of the file in this variable.
Returns:
true if the operation succeeds. Otherwise false.

Definition at line 240 of file OW_PosixFileSystem.cpp.

References OW_NAMESPACE::String::c_str().

void OW_NAMESPACE::FileSystem::initRandomFile const String &  file  ) 
 

Create a file with random data.

This is suitable for use with SSL initialization, If OpenSSL integration has been enabled.

Parameters:
filename The name of the file to write the random data to

Definition at line 445 of file OW_PosixFileSystem.cpp.

References OW_NAMESPACE::CryptographicRandomNumber::getNextNumber(), and i.

bool OW_NAMESPACE::FileSystem::isDirectory const String &  path  ) 
 

Returns:
true if file exists and is a directory

Definition at line 208 of file OW_PosixFileSystem.cpp.

References OW_NAMESPACE::String::c_str().

bool OW_NAMESPACE::FileSystem::isExecutable const String &  path  ) 
 

Tests if a file is executable.

This method is not available on platforms that do not have support for executable file attributes

Returns:
true if the file exists and is executable (and false otherwise).

Definition at line 175 of file OW_PosixFileSystem.cpp.

References _ACCESS, and OW_NAMESPACE::String::c_str().

bool OW_NAMESPACE::FileSystem::isLink const String &  path  ) 
 

Tests if a file is a symbolic link.

This method is not available on platforms that do not have support for symbolic links

Returns:
true if file exists and is a symbolic link

Definition at line 196 of file OW_PosixFileSystem.cpp.

References OW_NAMESPACE::String::c_str().

Referenced by OWBI1::BI1ProviderIFC::loadProviders(), and OW_NAMESPACE::CppProviderIFC::loadProviders().

bool OW_NAMESPACE::FileSystem::makeDirectory const String &  path,
int  mode = 0777
 

Create a directory.

Parameters:
path The name of the directory to create.
mode specifies the permissions to use.
Returns:
true if the operation succeeds. Otherwise false.

Definition at line 234 of file OW_PosixFileSystem.cpp.

References _MKDIR, and OW_NAMESPACE::String::c_str().

Referenced by OW_NAMESPACE::CIMRepository2::open().

File OW_NAMESPACE::FileSystem::openFile const String &  path  ) 
 

Open a file for read/write and return an File object that can be used for reading and writing.

Definition at line 118 of file OW_PosixFileSystem.cpp.

References OW_NAMESPACE::String::c_str().

Referenced by OW_NAMESPACE::HDB::checkFile(), OW_NAMESPACE::AssocDb::checkFile(), OW_NAMESPACE::HDB::getHandle(), OW_NAMESPACE::AssocDb::getHandle(), OW_NAMESPACE::dlSharedLibrary::isFakeLibrary(), OWBI1::TempFileEnumerationImplBase::readSize(), and OW_NAMESPACE::TempFileEnumerationImplBase::readSize().

File OW_NAMESPACE::FileSystem::openOrCreateFile const String &  path  ) 
 

Opens or creates the file for the given name.

Parameters:
path The name of the file to create.
Returns:
On success an File object that can be used for reading and writing. Otherwise a null File object.

Definition at line 153 of file OW_PosixFileSystem.cpp.

References OW_NAMESPACE::String::c_str().

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

size_t OW_NAMESPACE::FileSystem::read const FileHandle hdl,
void *  bfr,
size_t  numberOfBytes,
off_t  offset = -1L
 

Read data from file.

Parameters:
hdl The file handle to perform the read operation on.
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 324 of file OW_PosixFileSystem.cpp.

References OW_NAMESPACE::BinarySerialization::read().

String OW_NAMESPACE::FileSystem::readSymbolicLink const String &  path  ) 
 

Read the value of a symbolic link.

Parameters:
path Path to the symbolic link
Returns:
The target of the symbolic link
Exceptions:
FileSystemException,: ENOTDIR, ENOENT, EACCES, ELOOP, EINVAL, EIO, EFAULT, ENOMEM

Definition at line 508 of file OW_PosixFileSystem.cpp.

References OW_NAMESPACE::String::c_str(), MAXPATHLEN, OW_THROW_ERRNO, and OW_NAMESPACE::FileSystem::Path::realPath().

bool OW_NAMESPACE::FileSystem::removeDirectory const String &  path  ) 
 

Remove the given directory.

Parameters:
path The name of the directory to remove
Returns:
true if the operation succeeds. Otherwise false.

Definition at line 260 of file OW_PosixFileSystem.cpp.

References _RMDIR, and OW_NAMESPACE::String::c_str().

bool OW_NAMESPACE::FileSystem::removeFile const String &  path  ) 
 

Remove the given file.

Parameters:
path The name of the file to remove.
Returns:
true if the operation succeeds. Otherwise false.

Definition at line 266 of file OW_PosixFileSystem.cpp.

References _UNLINK, and OW_NAMESPACE::String::c_str().

Referenced by OW_NAMESPACE::LocalAuthentication::cleanupEntry(), OW_NAMESPACE::ServerSocketImpl::close(), OW_NAMESPACE::FileAppender::doProcessLogMessage(), OW_NAMESPACE::PidFile::removePid(), OW_NAMESPACE::CryptographicRandomNumber::saveRandomState(), and OW_NAMESPACE::BinaryRequestHandler::writeFileName().

bool OW_NAMESPACE::FileSystem::renameFile const String &  oldFileName,
const String &  newFileName
 

Rename the given file to the new name.

Parameters:
oldFileName The name of the file to rename
newFileName The new name for the oldFileName
Returns:
true if the operation succeeds. Otherwise false.

Definition at line 317 of file OW_PosixFileSystem.cpp.

References OW_NAMESPACE::String::c_str().

Referenced by OW_NAMESPACE::FileAppender::doProcessLogMessage().

void OW_NAMESPACE::FileSystem::rewind const FileHandle hdl  ) 
 

Position the file pointer associated with the given file handle to the beginning of the file.

Parameters:
hdl The file handle to use in the rewind operation.

Definition at line 411 of file OW_PosixFileSystem.cpp.

Referenced by OW_NAMESPACE::File::rewind().

off_t OW_NAMESPACE::FileSystem::seek const FileHandle hdl,
off_t  offset,
int  whence
 

Seek to a given offset within the file.

Parameters:
hdl The file handle to use in the seek operation.
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 384 of file OW_PosixFileSystem.cpp.

Referenced by OW_NAMESPACE::File::seek().

off_t OW_NAMESPACE::FileSystem::tell const FileHandle hdl  ) 
 

Parameters:
hdl The file handle to use in the tell operation.
Returns:
The current position in the file relative to the beginning of the file on success. Otherwise -1.

Definition at line 401 of file OW_PosixFileSystem.cpp.

Referenced by OW_NAMESPACE::File::tell().

size_t OW_NAMESPACE::FileSystem::write FileHandle hdl,
const void *  bfr,
size_t  numberOfBytes,
off_t  offset = -1L
 

Write data to a file.

Parameters:
hdl The file handle to perform the write operation on.
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 354 of file OW_PosixFileSystem.cpp.

References OW_NAMESPACE::BinarySerialization::write().


Generated on Thu Feb 9 09:17:13 2006 for openwbem by  doxygen 1.4.6