Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::File Class Reference

The File class represents a single file or directory. More...

#include <vcf/FoundationKit/File.h>

Inheritance diagram for VCF::File:

VCF::Object VCF::Directory List of all members.

Public Types

enum  FileAttributes {
  faNone = 0x00000000, faReadOnly = 0x00000001, faHidden = 0x00000002, faSystem = 0x00000004,
  faExecutable = 0x00000008, faDirectory = 0x00000010, faArchive = 0x00000020, faDevice = 0x00000040,
  faNormal = 0x00000080, faMaskFile = faReadOnly | faHidden | faSystem | faArchive | faNormal, faMaskFileExec = faReadOnly | faHidden | faSystem | faArchive | faNormal | faExecutable, faMaskDir = faMaskFile | faDirectory,
  faMaskAll = faMaskDir | faDevice | faExecutable
}
enum  StatMask {
  smStatNone = 0x0, smSize = 0x1, smAttributes = 0x2, smDateCreation = 0x4,
  smDateModified = 0x8, smDateAccess = 0x10, smMaskDateAll = smDateCreation | smDateModified | smDateAccess, smMaskAll = smMaskDateAll | smSize | smAttributes
}
enum  OpenFlags {
  ofNone = 0x0, ofRead = 0x1, ofWrite = 0x2, ofAppend = 0x4,
  ofStat = 0x8, ofReadWrite = ofRead | ofWrite
}
enum  ShareFlags { shNone = 0x0, shRead = 0x1, shWrite = 0x2, shMaskAny = shRead | shWrite }

Public Member Functions

 File (const String &fileName)
 File (const String &fileName, uint32 openFlags, ShareFlags shareFlags=File::shMaskAny)
 File ()
virtual ~File ()
FilePeergetPeer ()
 gets the file peer returns FilePeer* the file peer
virtual void setName (const String &fileName)
 sets the name of the File and creates the peer if it does not exists yet
String getName () const
String getOwner ()
 gets the owner of the file returns String the owner of the file
void resetStats ()
 reset infos like the fileAttributes, DateTime stamps
void updateStat (File::StatMask statMask=File::smMaskAll)
 updates the informations about the file from the file system
bool isDirectory ()
 tells if the file is a directory file on the file system returns true if it is a directory
bool isExecutable ()
 tells if the file has a read only attribute on the file system returns true if it is read only
bool isReadOnly ()
 tells if the file has a read only attribute on the file system returns true if it is read only
bool isSystem ()
 tells if the file has a system attribute on the file system returns true if it is a system file
bool isHidden ()
 tells if the file has a hidden attribute on the file system returns true if it is a hidden file
bool isArchive ()
 tells if the file has an archive attribute on the file system returns true if it is archived
bool isDevice ()
 tells if the file has a device attribute on the file system returns true if it is a device
bool isNormal ()
 tells if the file has a normal attribute on the file system returns true if it is a normal file
bool isReadable ()
 tells if a file can be opened for reading returns bool true if can be opened for reading
bool isWriteable ()
 tells if a file can be opened for writing returns bool true if can be opened for reading
VCF::uint64 getSize ()
 gets the size of the file in bytes
FileAttributes getFileAttributes ()
 gets the file attributes of the file
void setFileAttributes (const File::FileAttributes fileAttributes)
 set the fileAttributes of the file
DateTime getDateCreation ()
 gets the date of creation of the file
DateTime getDateModified ()
 gets the modification Date of the file
DateTime getDateAccess ()
 gets the date of the last access to the file
void setDateModified (const DateTime &date)
 set the modification Date of the file given in UTC time
void updateTime ()
 updates the file's modified time to the time when call is made the time is internally converted in UTC time before being assigned to the file
bool exists () const
 tells if a filename actually exists in the filesystem
void open ()
 opens the file using the current file name assigned to it
void openWithFileName (const String &fileName)
 opens a new file, closes the old one if previously opened
void openWithRights (const String &fileName, uint32 openFlags=File::ofRead, ShareFlags shareFlags=File::shMaskAny)
 opens a file with read/write access Closes the old one if previously opened
void close ()
 closes the file if open it can be called even if it was not opened
void create (const String &newFileName, uint32 openFlags=File::ofRead)
 creates a new file, as opposed to open, which simply opens an existing one.
void remove ()
 deletes the file from the file system
void move (const String &newFileName)
 renames/moves a file
void copyTo (const String &fileNameToCopyTo)
 copies the file into another one
FileInputStreamgetInputStream ()
 This returns a new instance of an InputStream that's attached to this file.
FileOutputStreamgetOutputStream ()
 This returns a new instance of an OutputStream that's attached to this file.
void internal_setStatMask (const StatMask &val)
 functions for modifying the file member values.
void internal_addToStatMask (const uint32 &val)
void internal_removeFromStatMask (const uint32 &val)
void internal_setFileName (const String &val)
void internal_setFileAttributes (const uint32 &val)

Static Public Member Functions

static bool exists (const String &fileName)
 tells if a filename actually exists in the filesystem

Protected Attributes

FilePeerfilePeer_
StatMask validStat_
uint32 openAccess_
String fileName_
String owner_
uint32 fileAttributes_

Detailed Description

The File class represents a single file or directory.

File functions that fail throw FileIO exceptions.


Member Enumeration Documentation

enum VCF::File::FileAttributes
 

Enumerator:
faNone 
faReadOnly 
faHidden 
faSystem 
faExecutable 
faDirectory 
faArchive 
faDevice 
faNormal 
faMaskFile 
faMaskFileExec 
faMaskDir 
faMaskAll 

enum VCF::File::OpenFlags
 

Enumerator:
ofNone 
ofRead 
ofWrite 
ofAppend 
ofStat 
ofReadWrite 

enum VCF::File::ShareFlags
 

Enumerator:
shNone 
shRead 
shWrite 
shMaskAny 

enum VCF::File::StatMask
 

Enumerator:
smStatNone 
smSize 
smAttributes 
smDateCreation 
smDateModified 
smDateAccess 
smMaskDateAll 
smMaskAll 


Constructor & Destructor Documentation

VCF::File::File const String fileName  ) 
 

VCF::File::File const String fileName,
uint32  openFlags,
ShareFlags  shareFlags = File::shMaskAny
 

VCF::File::File  ) 
 

virtual VCF::File::~File  )  [virtual]
 


Member Function Documentation

void VCF::File::close  ) 
 

closes the file if open it can be called even if it was not opened

void VCF::File::copyTo const String fileNameToCopyTo  ) 
 

copies the file into another one

Parameters:
fileNameToCopyTo the filename to create/overwrite.

void VCF::File::create const String newFileName,
uint32  openFlags = File::ofRead
 

creates a new file, as opposed to open, which simply opens an existing one.

If the file already exists then create will empty it's contents. If it is a directory name, a directory will be created.

Parameters:
newFileName the filename

bool VCF::File::exists  )  const [inline]
 

tells if a filename actually exists in the filesystem

Returns:
true if the file exists

static bool VCF::File::exists const String fileName  )  [static]
 

tells if a filename actually exists in the filesystem

Parameters:
fileName the filename to check for existence
Returns:
true if the filename exists

DateTime VCF::File::getDateAccess  ) 
 

gets the date of the last access to the file

Parameters:
DateTime the last access date

DateTime VCF::File::getDateCreation  ) 
 

gets the date of creation of the file

Parameters:
DateTime the creation date

DateTime VCF::File::getDateModified  ) 
 

gets the modification Date of the file

Parameters:
DateTime the desired modification date

File::FileAttributes VCF::File::getFileAttributes  )  [inline]
 

gets the file attributes of the file

Returns:
the file attributes

FileInputStream* VCF::File::getInputStream  ) 
 

This returns a new instance of an InputStream that's attached to this file.

Please note that it is the caller's responsibility to delete this when finished with it. Each call will create an new stream instance.

Returns:
FileInputStream - an new output stream instance. If the file is opened without an ofRead mask set, then this is NULL.
See also:
FileInputStream

InputStream

String VCF::File::getName  )  const [inline]
 

FileOutputStream* VCF::File::getOutputStream  ) 
 

This returns a new instance of an OutputStream that's attached to this file.

Please note that it is the caller's responsibility to delete this when finished with it. Each call will create an new stream instance. If the file is open without write access this method will return NULL.

Returns:
FileOutputStream - an new output stream instance. If the file is opened without an ofWrite mask set, then this is NULL.
See also:
FileOutputStream

OutputStream

String VCF::File::getOwner  ) 
 

gets the owner of the file returns String the owner of the file

FilePeer* VCF::File::getPeer  )  [inline]
 

gets the file peer returns FilePeer* the file peer

VCF::uint64 VCF::File::getSize  ) 
 

gets the size of the file in bytes

Parameters:
uint64 the size

void VCF::File::internal_addToStatMask const uint32 val  )  [inline]
 

void VCF::File::internal_removeFromStatMask const uint32 val  )  [inline]
 

void VCF::File::internal_setFileAttributes const uint32 val  )  [inline]
 

void VCF::File::internal_setFileName const String val  )  [inline]
 

void VCF::File::internal_setStatMask const StatMask val  )  [inline]
 

functions for modifying the file member values.

For internal use only.

bool VCF::File::isArchive  )  [inline]
 

tells if the file has an archive attribute on the file system returns true if it is archived

bool VCF::File::isDevice  )  [inline]
 

tells if the file has a device attribute on the file system returns true if it is a device

bool VCF::File::isDirectory  )  [inline]
 

tells if the file is a directory file on the file system returns true if it is a directory

bool VCF::File::isExecutable  ) 
 

tells if the file has a read only attribute on the file system returns true if it is read only

bool VCF::File::isHidden  )  [inline]
 

tells if the file has a hidden attribute on the file system returns true if it is a hidden file

bool VCF::File::isNormal  )  [inline]
 

tells if the file has a normal attribute on the file system returns true if it is a normal file

bool VCF::File::isReadable  )  [inline]
 

tells if a file can be opened for reading returns bool true if can be opened for reading

bool VCF::File::isReadOnly  )  [inline]
 

tells if the file has a read only attribute on the file system returns true if it is read only

bool VCF::File::isSystem  )  [inline]
 

tells if the file has a system attribute on the file system returns true if it is a system file

bool VCF::File::isWriteable  )  [inline]
 

tells if a file can be opened for writing returns bool true if can be opened for reading

void VCF::File::move const String newFileName  ) 
 

renames/moves a file

Parameters:
newFileName the filename

void VCF::File::open  ) 
 

opens the file using the current file name assigned to it

void VCF::File::openWithFileName const String fileName  ) 
 

opens a new file, closes the old one if previously opened

Parameters:
fileName the desired new filename

void VCF::File::openWithRights const String fileName,
uint32  openFlags = File::ofRead,
ShareFlags  shareFlags = File::shMaskAny
 

opens a file with read/write access Closes the old one if previously opened

Parameters:
fileName the desired new filename
openFlags 
shareFlags 

void VCF::File::remove  ) 
 

deletes the file from the file system

void VCF::File::resetStats  )  [inline]
 

reset infos like the fileAttributes, DateTime stamps

void VCF::File::setDateModified const DateTime date  ) 
 

set the modification Date of the file given in UTC time

Parameters:
date the desired modification date

void VCF::File::setFileAttributes const File::FileAttributes  fileAttributes  ) 
 

set the fileAttributes of the file

Parameters:
fileAttributes the desired attributes

virtual void VCF::File::setName const String fileName  )  [virtual]
 

sets the name of the File and creates the peer if it does not exists yet

Parameters:
fileName the name

Reimplemented in VCF::Directory.

void VCF::File::updateStat File::StatMask  statMask = File::smMaskAll  ) 
 

updates the informations about the file from the file system

Parameters:
statMask the mask indicating the infos we want to update

void VCF::File::updateTime  )  [inline]
 

updates the file's modified time to the time when call is made the time is internally converted in UTC time before being assigned to the file


Member Data Documentation

uint32 VCF::File::fileAttributes_ [protected]
 

String VCF::File::fileName_ [protected]
 

FilePeer* VCF::File::filePeer_ [protected]
 

uint32 VCF::File::openAccess_ [protected]
 

String VCF::File::owner_ [protected]
 

StatMask VCF::File::validStat_ [protected]
 


The documentation for this class was generated from the following file:
   Comments or Suggestions?    License Information