IFile

This class provides a surrogate object for a file.

Do not derive your own classes from this class.


IFile - Member Functions and Data by Group

Constructors & Destructor

Use the functions in this group to construct or destroy objects of class IFile.


[view class]
~IFile
Destroys the IFile object.
public:
virtual ~IFile()
Destructor.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
IFile
Constructs an IFile object.


Overload 1
public:
IFile(const IFile& copy)
Use the copy constructor to create an IFile object copied from the given one.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 2
public:
IFile()
Default constructor.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Assignment Operator

Use this operator to replace the existing object with the assigned, given one.


[view class]
operator =
Assigns an IFile to an entity object, with type checking.
public:
IFile& operator =(const IFileSystemEntity& right)
The assignment operator.

copy
If this entity refers to a physical file, the IFile now refers to the same object. If not, an exception is thrown.

Exception

IEntityTypeMismatch thrown if the specified entity is not a file

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Class Constants

The kind of the file system entity. A form of homegrown RTTI.


[view class]
kKind
public:
static const IFileKind _IMPORT kKind
An IFileKind constant that identifies the IFile class.

This constant is used for dynamic type checking.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Setting and Getting File Values

Use the functions in this group to set and get a file's size, get a file's modification time, or to create a temporary file.


[view class]
createTemporary
public:
static IFile createTemporary( const IFileName& name = uniqueName ( ), const IFileSize initialSize = 0u )
Creates a temporary file. Creates a temporary file in the appropriate place for temporary storage on the current system. The file is only "temporary" in that sense; it is not automatically deleted when the IFile object is destroyed.

dirName
The name for the temporary file. If none is provided, a unique name is generated.
initialSize
The initial size of the created file, in bytes. If none is specified, the file is empty.

Exception

IEntityExists thrown if a name is provided and a a temporary file with that name already exists.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
getRecord
public:
IFSFileRecord* getRecord() const
Returns the file system record.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
setModificationTime
public:
void setModificationTime( const ITimeStamp& modificationTime ) const
Sets the file's modification time. Subsequent calls to IFileSystemEntity::modificationTime return the new value.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
setSize
public:
void setSize(IFileSize newSize)
Sets the file's size to the specified size. If the current size is larger, the file is truncated. If the current size is smaller, the file is padded with arbitrary data.

newSize
Desired size of the file, in bytes.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
size
public:
IFileSize size() const
Returns the size of the file, in bytes.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Special "Downcast" Constructors

Use the constructors in this group to create IFile objects based on the given information, such as a host path name, a partial path name, a file system entity, or a file system directory record.


[view class]
IFile
Constructs an IFile object.


Overload 1
Constucts an IFile from a portable path name.
public:
IFile( const IPathName& path, ECreateFlags flags = kMustExist )
Use this constructor to create an IFile object from the given portable path name.

path
The portable path name.

flags
Specifies whether the constructor creates or overwrites a file on the disk.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 2
Constructs an IFile from an entity object, with type checking.
public:
IFile(const IFileSystemEntity& copy)
Use this constructor to create an IFile object that is constructed from a copy of the given file system entity, with type checking.

copy
If this entity refers to a physical file, the construced IFile refers to the same object. If not, an exception is thrown.

Exception

IEntityTypeMismatch thrown if the specified entity is not a file

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 3
Constucts an IFile from a host-specific path name.
public:
IFile( const IHostPathName& path, ECreateFlags flags = kMustExist, const ICompoundNameParser& = defaultParser ( ) )
Use this constructor to create an IFile object from a host-specific path name.

path
Text string containing the host-specific path name.

parser
The path name parser which should be used to parse the provided path. If no parser is specified, the default for the current system is used.

flags
Specifies whether the constructor creates or overwrites a file on the disk.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 4
public:
IFile(IFSFileRecord* Record)
Use this constructor to create an IFile object from the given file system record.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Streaming Support

Use the function in this group to create a stream.


[view class]
createStream
public:
IDataStream* createStream( int modeForMe = in + out, int modeForOthers = 0, IDataStream::EStreamEncoding encoding = IDataStream::kInteroperableBinary )
Creates an OpenClass stream for I/O on the this file.

modeForMe
The mode in which the file should be opened. See IFileIOStream::IFileIOStream for details.

modeForOthers
Specifies the modes in which you want to allow others to open the file concurrently. See IFileIOStream::IFileIOStream for details.

encoding
The format for data on the stream. See IDataStream::EStreamEncoding for details.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


IFile - Enumerations


[view class]
EOpenMode
enum EOpenMode { in=1, 
                 out=2, 
                 ate=4, 
                 app=010, 
                 trunc=020 }

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


IFile - Inherited Member Functions and Data

Inherited Public Functions

IFileSystemEntity
IMStreamable

Inherited Public Data

Inherited Protected Functions

IMStreamable
IFileSystemEntity

Inherited Protected Data