Generic File. More...

#include <rfile.h>

Inheritance diagram for RFile:
[legend]
Collaboration diagram for RFile:
[legend]

Public Member Functions

 RFile (void)
 
 RFile (const RURI &uri)
 
 RFile (const RFile &file)
 
virtual void Open (RIO::ModeType mode)
 
void Open (const RURI &uri, RIO::ModeType mode)
 
virtual void Close (void)
 
int Compare (const RFile &file) const
 
int Compare (const RFile *file) const
 
int Compare (const RString &uri) const
 
const RURIGetURI (void) const
 
void SetURI (const RURI &uri)
 
const RString GetFileName (void) const
 
virtual ~RFile (void)
 

Static Public Member Functions

static RChar GetDirSeparator (void)
 
static void RemoveFile (const RURI &uri)
 
static void RenameFile (const RURI &olduri, const RURI &newuri)
 
static RURI GetTempFile (void)
 
static bool Exists (const RURI &uri)
 
static bool IsDir (const RURI &uri)
 

Protected Attributes

RIO::ModeType Mode
 
RURI URI
 

Detailed Description

Generic File.

The RFile class represents a file (text files, directories...).

Constructor & Destructor Documentation

RFile ( void  )

Default constructor.

RFile ( const RURI uri)

Construct a file.

Parameters
uriURI of the file.
RFile ( const RFile file)

Copy constructor of a file.

Parameters
fileFile.
virtual ~RFile ( void  )
virtual

Destruct the file.

Member Function Documentation

virtual void Open ( RIO::ModeType  mode)
virtual

Open the file

Parameters
modeThe open mode for the file.

Reimplemented in RXMLParser, RTextFile, RKeyValueFile< K >, RIOFile, RRecFile< C, bOrder >, RBlockFile, RCSVFile, RXMLFile, RBinaryFile, RDir, and RHTMLFile.

void Open ( const RURI uri,
RIO::ModeType  mode 
)

Open the file

Parameters
uriURI of the file.
modeThe open mode for the file.
virtual void Close ( void  )
virtual
int Compare ( const RFile file) const

Compare two files by comparing their name.

See also
R::RContainer
Parameters
fileFile.
Returns
int
int Compare ( const RFile file) const

Compare two files by comparing their name.

See also
R::RContainer
Parameters
fileFile.
Returns
int
int Compare ( const RString uri) const

Compare the uri of a file with a given string.

See also
R::RContainer
Parameters
uriURI.
Returns
int
const RURI& GetURI ( void  ) const

Return the URI of the file including.

void SetURI ( const RURI uri)

Set the URI of the file.

Parameters
uriURI of the file.
const RString GetFileName ( void  ) const

Return the name of the file. If the fullname doesn't have a slash at the end, the part between the last slash and the end of the fullname is considered to be the file name. If the fullname has a slash at the end, an empty string is returned here.

Returns
a string containing the name.
static RChar GetDirSeparator ( void  )
static

Get the separator used for the directories.

static void RemoveFile ( const RURI uri)
static

Remove a file from the disk.

Parameters
uriURI of the file.
static void RenameFile ( const RURI olduri,
const RURI newuri 
)
static

Rename a file from the disk.

Parameters
olduriOld URI of the file.
newuriNew URI of the file.
static RURI GetTempFile ( void  )
static

Get a name for a temporary file.

Attention
Under Unix-like OS (such as Linux), a empty file is created by the OS to ensure that a given name cannot be used by multiple calls. It can be necessary to delete manually the file (normally, the temporary directory is automatically emptied).
Returns
Name of the file.
static bool Exists ( const RURI uri)
static

Test if an URI correspond to an existing file or directory that can be accessed. If the URI is correct but the calling application has the not the correct rights, the function returns false.

Parameters
uriURI to test.
static bool IsDir ( const RURI uri)
static

Test if an URI is a directory or not. If the directory exists but the calling application has the not the correct rights, the function returns false.

Parameters
uriURI to test.

Field Documentation

RIO::ModeType Mode
protected

How the file has to be used.

RURI URI
protected

URI of the File.