Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

mortic::IFile Class Reference

A read/write file wrapper. More...

Inheritance diagram for mortic::IFile:

mortic::IObject List of all members.

Public Member Functions

 IFile (IRoot *root)
 Constructor.
virtual void close ()=0
 Close the File.
virtual void flush ()=0
 Flush the File Buffers.
virtual std::string read (unsigned int size=0)=0
 Read from the file.
virtual void write (std::string s)=0
 Write to the file.
virtual unsigned int tell ()=0
 Get the position in the file.
virtual void seek (unsigned int s)=0
 Set the position in the file.
virtual bool eof ()=0
 Returns if at end of file.
virtual bool isOpen ()=0
 Returns if the file is open.
virtual std::string getPath ()=0
 Returns the path of the file.

Detailed Description

A read/write file wrapper.

This class represents a file loaded from IFileManager. File abstraction is useful, because it allows you to read from different sources transparently. For example, you could read from an HTTP stream just like a normal file! Note: always open from IFileManager. Never make your own instance.

Definition at line 36 of file IFile.h.


Constructor & Destructor Documentation

mortic::IFile::IFile IRoot root  )  [inline]
 

Constructor.

Definition at line 40 of file IFile.h.


Member Function Documentation

virtual void mortic::IFile::close  )  [pure virtual]
 

Close the File.

After the file is closed, you can no longer read or write. Calls flush() before closing. Always remember to close a file after you're done!

See also:
flush()

virtual bool mortic::IFile::eof  )  [pure virtual]
 

Returns if at end of file.

This function returns whether or not you have reached the end of the file.

Returns:
true if at end of file

virtual void mortic::IFile::flush  )  [pure virtual]
 

Flush the File Buffers.

Flushing after a write() will ensure that what you have written is actually written. files don't normally flush after every write because it is more efficient, but somethimes what is written must be immediatly available.

virtual std::string mortic::IFile::getPath  )  [pure virtual]
 

Returns the path of the file.

This path is in VFS terms, and allows you to reopen a closed file, and generally snoop around. Please note that remappings and unmountings may have made this file path move or dissappear, although it would probably work. Always use IFileManager::exists().

Returns:
the path of the file, as it was opened

virtual bool mortic::IFile::isOpen  )  [pure virtual]
 

Returns if the file is open.

This returns whether or not you can read or write from this file.

Returns:
true if file is open

virtual std::string mortic::IFile::read unsigned int  size = 0  )  [pure virtual]
 

Read from the file.

Only works if the file was opened in read mode.

  • size - the number of bytes (charecters) to read. 0 = all
    Returns:
    the string that was read.
    See also:
    write()

virtual void mortic::IFile::seek unsigned int  s  )  [pure virtual]
 

Set the position in the file.

  • s - new position in the file, 0 = first byte
    See also:
    tell()

virtual unsigned int mortic::IFile::tell  )  [pure virtual]
 

Get the position in the file.

Returns:
the current position in the file, 0 = first byte
See also:
seek()

virtual void mortic::IFile::write std::string  s  )  [pure virtual]
 

Write to the file.

Only works if the file was opened in write mode.

  • s - the string to write
    See also:
    read()


Generated on Sat Dec 30 21:21:59 2006 for mortic by  doxygen 1.4.4