PixelLightAPI  .
Protected Member Functions | Protected Attributes
PLCore::FileImpl Class Reference

Abstract base class for platform specific file object implementations. More...

#include <FileImpl.h>

Inheritance diagram for PLCore::FileImpl:
Inheritance graph
[legend]

List of all members.

Protected Member Functions

PLCORE_API FileImpl (const Url &cUrl, const FileAccess *pAccess)
 Constructor.
virtual PLCORE_API ~FileImpl ()
 Destructor.
virtual bool Exists () const =0
 Check if the file or directory exists.
virtual bool IsFile () const =0
 Check if the object is a regular file.
virtual bool IsDirectory () const =0
 Check if the object is a directory.
virtual bool CopyTo (const String &sDest, bool bOverwrite) const =0
 Copy the file or directory to a new location.
virtual bool MoveTo (const String &sDest)=0
 Move the file or directory to a new location.
virtual bool Rename (const String &sName)=0
 Rename the file or directory.
virtual bool CreateNewFile (bool bAlways)=0
 Create a file.
virtual bool CreateNewDirectory ()=0
 Create a directory.
virtual bool Delete ()=0
 Delete a file.
virtual bool DeleteDirectory ()=0
 Delete a directory.
virtual void Close ()=0
 Close the file or directory.
virtual bool Open (uint32 nAccess, String::EFormat nStringFormat=String::ASCII)=0
 Open the file for reading and/or writing.
virtual bool IsOpen () const =0
 Returns whether the file is open.
virtual bool IsReadable () const =0
 Returns whether the file is readable.
virtual bool IsWritable () const =0
 Returns whether the file is writable.
virtual String::EFormat GetStringFormat () const =0
 Returns the string encoding format to use when dealing with string functions.
virtual bool IsEof () const =0
 Returns whether end of file has been reached.
virtual int GetC ()=0
 Reads a character.
virtual bool PutC (int nChar)=0
 Writes a character.
virtual String GetS ()=0
 Reads a string.
virtual int PutS (const String &sString)=0
 Writes a string.
virtual uint32 Read (void *pBuffer, uint32 nSize, uint32 nCount)=0
 Reads the given number of bytes.
virtual uint32 Write (const void *pBuffer, uint32 nSize, uint32 nCount)=0
 Writes the given number of bytes.
virtual bool Flush ()=0
 Flushes the file buffer.
virtual bool Seek (int32 nOffset, uint32 nLocation)=0
 Sets the starting position.
virtual int32 Tell () const =0
 Gets the current position of the file pointer.
virtual uint32 GetSize () const =0
 Returns the file size.
virtual FileSearchImplCreateSearch ()=0
 Create a file searcher for the directory.

Protected Attributes

Url m_cUrl
const FileAccessm_pAccess

Detailed Description

Abstract base class for platform specific file object implementations.

Note:
  • Implementation of the state design pattern, this class is the state of the 'FileObject'-context

Constructor & Destructor Documentation

PLCORE_API PLCore::FileImpl::FileImpl ( const Url cUrl,
const FileAccess pAccess 
) [protected]

Constructor.

Parameters:
[in]cUrlURL of the file or directory
[in]pAccessAdditional file access information (can be a null pointer)
virtual PLCORE_API PLCore::FileImpl::~FileImpl ( ) [protected, virtual]

Destructor.


Member Function Documentation

virtual bool PLCore::FileImpl::Exists ( ) const [protected, pure virtual]

Check if the file or directory exists.

Returns:
'true', if the object is existing, else 'false'
virtual bool PLCore::FileImpl::IsFile ( ) const [protected, pure virtual]

Check if the object is a regular file.

Returns:
'true', if the object is a file
virtual bool PLCore::FileImpl::IsDirectory ( ) const [protected, pure virtual]

Check if the object is a directory.

Returns:
'true', if the object is a directory
virtual bool PLCore::FileImpl::CopyTo ( const String sDest,
bool  bOverwrite 
) const [protected, pure virtual]

Copy the file or directory to a new location.

Parameters:
[in]sDestURL of the destination
[in]bOverwriteShall the file be overwritten if it already exists?
Returns:
'true', if all went fine, else 'false'
virtual bool PLCore::FileImpl::MoveTo ( const String sDest) [protected, pure virtual]

Move the file or directory to a new location.

Parameters:
[in]sDestURL of the destination
Returns:
'true', if all went fine, else 'false'
virtual bool PLCore::FileImpl::Rename ( const String sName) [protected, pure virtual]

Rename the file or directory.

Parameters:
[in]sNameNew filename (filename only, no path)
Returns:
'true', if all went fine, else 'false'
virtual bool PLCore::FileImpl::CreateNewFile ( bool  bAlways) [protected, pure virtual]

Create a file.

Parameters:
[in]bAlwaysIf 'true', the file is created (and therefore overwritten) if it already exists
Returns:
'true', if all went fine, else 'false'
virtual bool PLCore::FileImpl::CreateNewDirectory ( ) [protected, pure virtual]

Create a directory.

Returns:
'true', if all went fine, else 'false'
virtual bool PLCore::FileImpl::Delete ( ) [protected, pure virtual]

Delete a file.

Returns:
'true', if all went fine, else 'false'
virtual bool PLCore::FileImpl::DeleteDirectory ( ) [protected, pure virtual]

Delete a directory.

Returns:
'true', if all went fine, else 'false'
virtual void PLCore::FileImpl::Close ( ) [protected, pure virtual]

Close the file or directory.

virtual bool PLCore::FileImpl::Open ( uint32  nAccess,
String::EFormat  nStringFormat = String::ASCII 
) [protected, pure virtual]

Open the file for reading and/or writing.

Parameters:
[in]nAccessAccess mode (see EAccess)
[in]nStringFormatString encoding format to use when dealing with string functions
Returns:
'false' on error, else 'true'
virtual bool PLCore::FileImpl::IsOpen ( ) const [protected, pure virtual]

Returns whether the file is open.

Returns:
'true', if the file is open, else 'false'
virtual bool PLCore::FileImpl::IsReadable ( ) const [protected, pure virtual]

Returns whether the file is readable.

Returns:
'true', if the file can be read, else 'false'
virtual bool PLCore::FileImpl::IsWritable ( ) const [protected, pure virtual]

Returns whether the file is writable.

Returns:
'true', if the file can be written, else 'false'
virtual String::EFormat PLCore::FileImpl::GetStringFormat ( ) const [protected, pure virtual]

Returns the string encoding format to use when dealing with string functions.

Returns:
String encoding format to use when dealing with string functions
virtual bool PLCore::FileImpl::IsEof ( ) const [protected, pure virtual]

Returns whether end of file has been reached.

Returns:
'true', if the end of the file has been reached, else 'false'
virtual int PLCore::FileImpl::GetC ( ) [protected, pure virtual]

Reads a character.

Returns:
A character from file, < 0 if there was an error
virtual bool PLCore::FileImpl::PutC ( int  nChar) [protected, pure virtual]

Writes a character.

Parameters:
[in]nCharCharacter to write
Returns:
'true' if all went fine, else 'false' (maybe file is read only)
virtual String PLCore::FileImpl::GetS ( ) [protected, pure virtual]

Reads a string.

Returns:
Read string
virtual int PLCore::FileImpl::PutS ( const String sString) [protected, pure virtual]

Writes a string.

Parameters:
[in]sStringString which should be written into the file
Returns:
Number of bytes written, 0 if nothing was written, < 0 if there was an error
virtual uint32 PLCore::FileImpl::Read ( void *  pBuffer,
uint32  nSize,
uint32  nCount 
) [protected, pure virtual]

Reads the given number of bytes.

Parameters:
[out]pBufferBuffer were the data should be copied in (MUST valid and large enough!)
[in]nSizeItem size in bytes
[in]nCountMaximum number of items to be read
Returns:
Number of fully read items, if != 'nCount' an error occurred
virtual uint32 PLCore::FileImpl::Write ( const void *  pBuffer,
uint32  nSize,
uint32  nCount 
) [protected, pure virtual]

Writes the given number of bytes.

Parameters:
[in]pBufferBuffer with the data which should be written into the file (MUST valid and large enough!)
[in]nSizeItem size in bytes
[in]nCountMaximum number of items to be written
Returns:
Number of fully written items, if != 'nCount' an error occurred
virtual bool PLCore::FileImpl::Flush ( ) [protected, pure virtual]

Flushes the file buffer.

Returns:
'true' if all went fine, else 'false'
virtual bool PLCore::FileImpl::Seek ( int32  nOffset,
uint32  nLocation 
) [protected, pure virtual]

Sets the starting position.

Parameters:
[in]nOffsetFile offset in bytes relative to the given location
[in]nLocationLocation ("File::ESeek"-type)
Returns:
'true' if all went fine, else 'false'
virtual int32 PLCore::FileImpl::Tell ( ) const [protected, pure virtual]

Gets the current position of the file pointer.

Returns:
The current byte position of the file pointer, < 0 if there was an error
virtual uint32 PLCore::FileImpl::GetSize ( ) const [protected, pure virtual]

Returns the file size.

Returns:
File size in bytes
virtual FileSearchImpl* PLCore::FileImpl::CreateSearch ( ) [protected, pure virtual]

Create a file searcher for the directory.

Returns:
Pointer to a file searcher, or a null pointer on error

Member Data Documentation

URL of the file or directory

File access information, can be a null pointer


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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:25
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported