Om  1.0.0
A universal framework for multimedia simulation
Classes | Public Types | Public Member Functions | List of all members
om::fs::File Class Reference

A class that represents a file in the global file system. More...

#include <omFile.h>

Inheritance diagram for om::fs::File:
om::fs::FileSystemNode

Public Types

enum  AccessType { READ = (1 << 0), WRITE = (1 << 1), READ_WRITE = READ | WRITE, UNDEFINED = 0 }
 An enum that describes the access type for a file. More...
 

Public Member Functions

 File (const Path &newPath)
 Create a file object that corresponds to the specified path. More...
 
 File (const File &other)
 Create a new file object that refers to the same file as another file. More...
 
 ~File ()
 Destory this file, releasing all file resources and unmapping the file if mapped. More...
 
Fileoperator= (const File &other)
 Assign the reference to another to this file. More...
 
virtual Bool isFile () const
 Return whether or not the file system node is a file. More...
 
virtual Bool isDirectory () const
 Return whether or not the file system node is a directory. More...
 
virtual Bool exists () const
 Return whether or not this file system node exists. More...
 
virtual LargeSize getSize () const
 Return the total size of the file system node. More...
 
virtual Bool setName (const UTF8String &newName)
 Set the name of the file, the last component of its path. More...
 
virtual Bool create ()
 Create this file if it doesn't exist. More...
 
virtual Bool remove ()
 Delete this file system node and all children (if it is a directory). More...
 
Bool erase ()
 Erase this file or create it if it doesn't exist. More...
 
Bool isMapped () const
 Return whether or not this file is currently memory mapped. More...
 
void * map (AccessType accessType)
 Memory-map the entire contents of this file and return a pointer to the memory. More...
 
void * map (AccessType accessType, LargeIndex offset, Size length)
 Memory-map a portion of this file and return a pointer to the memory. More...
 
Bool unmap (void *memory)
 Unmap a previously-mapped memory location for this file. More...
 
void unmap ()
 Unmap this file entirely, closing it for access. More...
 
- Public Member Functions inherited from om::fs::FileSystemNode
virtual ~FileSystemNode ()
 Destroy a file system node object. More...
 
UTF8String getName () const
 Return the name of the file system node, the last component of its path. More...
 
UTF8String getExtension () const
 Return a string representing the extension of this node's file name. More...
 
const PathgetPath () const
 Return a path object representing the path to this file system node. More...
 
const UTF8String & getPathString () const
 Return a string representing the path to the file system node. More...
 
Bool isAtRoot () const
 Return whether or not the file system node is at the root level of the file system. More...
 
virtual time::Date getDateCreated () const
 Return the date when this file system node was created. More...
 
virtual time::Date getDateModified () const
 Return the date when this file system node was last modified. More...
 

Additional Inherited Members

- Protected Member Functions inherited from om::fs::FileSystemNode
 FileSystemNode (const UTF8String &newPathString)
 Create a file system node that is represented by the specified path string. More...
 
 FileSystemNode (const Path &newPath)
 Create a file system node that is represented by the specified path. More...
 
- Protected Attributes inherited from om::fs::FileSystemNode
Path path
 The path to this file system node. More...
 

Detailed Description

A class that represents a file in the global file system.

A File object can represent a local file, network file, or any other type of file resource. This class also allows the user to create and delete files with the given file path and determine other basic information about the file.

Member Enumeration Documentation

An enum that describes the access type for a file.

Enumerator
READ 

File access where reading is enabled.

WRITE 

File access where writing is enabled.

READ_WRITE 

File access where reading and writing is enabled.

UNDEFINED 

An undefined file access type.

Constructor & Destructor Documentation

om::fs::File::File ( const Path newPath)

Create a file object that corresponds to the specified path.

om::fs::File::File ( const File other)

Create a new file object that refers to the same file as another file.

om::fs::File::~File ( )

Destory this file, releasing all file resources and unmapping the file if mapped.

Member Function Documentation

File& om::fs::File::operator= ( const File other)

Assign the reference to another to this file.

virtual Bool om::fs::File::isFile ( ) const
virtual

Return whether or not the file system node is a file.

Implements om::fs::FileSystemNode.

virtual Bool om::fs::File::isDirectory ( ) const
virtual

Return whether or not the file system node is a directory.

Implements om::fs::FileSystemNode.

virtual Bool om::fs::File::exists ( ) const
virtual

Return whether or not this file system node exists.

Implements om::fs::FileSystemNode.

virtual LargeSize om::fs::File::getSize ( ) const
virtual

Return the total size of the file system node.

For files, this is the total size of the file. For directories, this is the total size of all child file system nodes. If the file does not exist, the size 0 is returned.

Implements om::fs::FileSystemNode.

virtual Bool om::fs::File::setName ( const UTF8String &  newName)
virtual

Set the name of the file, the last component of its path.

Implements om::fs::FileSystemNode.

virtual Bool om::fs::File::create ( )
virtual

Create this file if it doesn't exist.

If the file system node already exists, no operation is performed and FALSE is returned. If the creation operation was not successful, FALSE is returned. Otherwise, TRUE is returned and the node is created.

Implements om::fs::FileSystemNode.

virtual Bool om::fs::File::remove ( )
virtual

Delete this file system node and all children (if it is a directory).

Implements om::fs::FileSystemNode.

Bool om::fs::File::erase ( )

Erase this file or create it if it doesn't exist.

If there was an error during creation, FALSE is returned. Otherwise, TRUE is returned and the file is erased.

Bool om::fs::File::isMapped ( ) const
inline

Return whether or not this file is currently memory mapped.

void* om::fs::File::map ( AccessType  accessType)

Memory-map the entire contents of this file and return a pointer to the memory.

If the function succeeds, the file is mapped to a memory address via virtual memory, and a pointer to the file's contents is returned. The file has the given access type. Writes to the memory will asynchronously update the file contents.

If the function fails, NULL is returned. The function can fail if the file is too big to fit into the program's virtual address space.

void* om::fs::File::map ( AccessType  accessType,
LargeIndex  offset,
Size  length 
)

Memory-map a portion of this file and return a pointer to the memory.

If the function succeeds, the file contents with the specified offset and length are mapped to a memory address via virtual memory, and a pointer to the file's contents at that offset is returned. The file has the given access type. Writes to the memory will asynchronously update the file contents.

The offset must be a multiple of the virtual memory page size.

If the function fails, NULL is returned.

Bool om::fs::File::unmap ( void *  memory)

Unmap a previously-mapped memory location for this file.

This method does not completely unmap the file, only a region of the file. To finish unmapping, call unmap().

The pointer must be the same as a previously returned mapping pointer.

void om::fs::File::unmap ( )

Unmap this file entirely, closing it for access.


The documentation for this class was generated from the following file: