|
OpenTop 1.3 | |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||
SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD |
#include "ot/io/FileSystem.h"
OpenTop treats file pathnames and handles as abstract data types which only have meaning when combined with a FileSystem object.
A FileSystem knows how pathnames are constructed and how relative pathnames can be combined to create an absolute pathname. A FileSystem also knows how to perform file i/o, with the consequence that all OpenTop file i/o is delegated to a FileSystem object.
There can be more than one FileSystem object, each one representing different file systems supported by the target platform. However, there can be only one global FileSystem. The global FileSystem is used by most OpenTop classes that have to resolve or open files using abstract pathnames.
The global FileSystem object can be set by applications by use of the SetFileSystem() method.
OpenTop provides concrete FileSystem implementations that are adequate for most circumstances.
Method Summary | |
virtual String |
canonicalize(const String& path) const Returns a canonical form of path. |
virtual bool |
checkAccess(const String& path, AccessMode mode) const=0 Tests if file path can be opened with the specified mode. |
virtual void |
closeFile(FileDescriptor* pFD) const=0 Closes the file specified by the FileDescriptor pFD. |
virtual void |
createDirectory(const String& path) const=0 Creates a directory. |
virtual void |
deleteFile(const String& path) const=0 Deletes the named file or directory from the file system. |
virtual RefPtr< FileDescriptor > |
getConsoleFD(ConsoleStream stream) const=0 Returns a FileDescriptor for one of the standard Console streams. |
virtual String |
getCurrentDirectory() const=0 Returns the current directory for the active process. |
virtual int |
getFileAttributeFlags(const String& path) const=0 Returns an integer used as a bit field, each bit representing a file attribute. |
static RefPtr< FileSystem > |
GetFileSystem() Returns a reference to the global FileSystem object. |
virtual DateTime |
getLastModifiedTime(const String& path) const=0 Returns the time the file was last modified. |
virtual size_t |
getLength(const String& path) const=0 Returns the length (in bytes) of the file. |
virtual size_t |
getPrefixLength(const String& path) const=0 Returns the length of the prefix of an abstract path name. |
virtual String |
getSeparator() const Returns the separator character as a String. |
virtual CharType |
getSeparatorChar() const=0 Returns the character which is used to separate the parts of a hierarchical path name. |
virtual bool |
isAbsolute(const String& path) const=0 Tests if path represents an absolute file name. |
virtual bool |
isCaseSensitive() const=0 Tests if the FileSystem represents files in a case-sensitive manner. |
virtual std::list< String > |
listDirectory(const String& path) const=0 Returns a list of the files contained within a directory. |
virtual String |
normalize(const String& path) const Converts a pathname into normalized form. |
virtual RefPtr< FileDescriptor > |
openFile(const String& path, int accessMode, CreationDisp creationDisp, int attributes) const=0 Opens a file and returns a FileDescriptor representing the open file. |
virtual size_t |
readFile(FileDescriptor* pFD, Byte* pBuffer, size_t bufLen) const=0 Reads up to bufLen bytes from an open file into the supplied buffer. |
virtual void |
rename(const String& path1, const String& path2) const=0 Renames a file. |
virtual String |
resolve(const String& path) const Resolve a relative pathname. |
virtual String |
resolve(const String& parent, const String& child) const Resolves a relative child pathname against a parent pathname to create an absolute pathname. |
static void |
SetFileSystem(FileSystem* pFileSystem) Sets the global FileSystem object. |
virtual void |
setLastModifiedTime(const String& path, const DateTime& time) const=0 Updates the date and time a file was last modified. |
virtual void |
setReadOnly(const String& path, bool bReadOnly) const=0 Changes a file's access permissions to be 'read only'. |
virtual void |
writeFile(FileDescriptor* pFD, const Byte* pBuffer, size_t bufLen) const=0 Writes an array of bytes to an open file. |
Methods inherited from class ot::ManagedObject |
addRef, getRefCount, onFinalRelease, operator=, release |
Enumerations |
enum { |
EndOfFile =-1} |
/* end of file reached */ |
enum AccessMode { |
ReadAccess = 0x01, |
/* Request read access */ |
|
WriteAccess = 0x02} |
/* Request write access */ |
enum Attribute { |
Exists = 0x01, |
/* File exists */ |
|
RegularFile = 0x02, |
/* A regular file i.e. not a directory */ |
|
Directory = 0x04, |
/* File is a directory */ |
|
Hidden = 0x08, |
/* File is hidden */ |
|
ReadOnly = 0x10} |
/* File is read-only for the current process */ |
enum ConsoleStream { |
Stdin = 0, |
/* standard input */ |
|
Stdout = 1, |
/* standard output */ |
|
Stderr = 2} |
/* standard error */ |
enum CreationDisp { |
OpenExisting, |
/* open existing file only */ |
|
OpenCreateAppend, |
/* open existing or create new, preserve existing contents */ |
|
OpenCreateExclusive, |
/* create non-existing file only */ |
|
OpenCreateTruncate} |
/* open existing or create new, destroy existing contents */ |
Method Detail |
virtual String canonicalize(const String& path) const
For example, the canonical form of the path docs/../images/image1.jpg may be /home/http/images/image1.jpg if /home/http/ is the current directory.
virtual bool checkAccess(const String& path, AccessMode mode) const=0
virtual void closeFile(FileDescriptor* pFD) const=0
virtual void createDirectory(const String& path) const=0
virtual void deleteFile(const String& path) const=0
FileNotFoundException
- IOException
- virtual RefPtr< FileDescriptor > getConsoleFD(ConsoleStream stream) const=0
virtual String getCurrentDirectory() const=0
virtual int getFileAttributeFlags(const String& path) const=0
static RefPtr< FileSystem > GetFileSystem()
virtual DateTime getLastModifiedTime(const String& path) const=0
FileNotFoundException
- IOException
- virtual size_t getLength(const String& path) const=0
FileNotFoundException
- IOException
- virtual size_t getPrefixLength(const String& path) const=0
virtual String getSeparator() const
virtual CharType getSeparatorChar() const=0
virtual bool isAbsolute(const String& path) const=0
virtual bool isCaseSensitive() const=0
virtual std::list< String > listDirectory(const String& path) const=0
virtual String normalize(const String& path) const
path
- virtual RefPtr< FileDescriptor > openFile(const String& path, int accessMode, CreationDisp creationDisp, int attributes) const=0
IOException
- virtual size_t readFile(FileDescriptor* pFD, Byte* pBuffer, size_t bufLen) const=0
pBuffer
- bufLen
- IllegalArgumentException
- NullPointerException
- IOException
- virtual void rename(const String& path1, const String& path2) const=0
virtual String resolve(const String& path) const
virtual String resolve(const String& parent, const String& child) const
parent
- child
- static void SetFileSystem(FileSystem* pFileSystem)
To ensure that the passed object exists for as long as the application needs it, the FileSystem object is registered with the system's ObjectManager which holds a (counted) reference to it until system termination.
virtual void setLastModifiedTime(const String& path, const DateTime& time) const=0
virtual void setReadOnly(const String& path, bool bReadOnly) const=0
virtual void writeFile(FileDescriptor* pFD, const Byte* pBuffer, size_t bufLen) const=0
pBuffer
- bufLen
- NullPointerException
- IOException
-
|
OpenTop 1.3 | |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||
SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD |