TFile

Back Up Next

TFile

Header File
    <owl/file.h>

Description
    The TFile class encapsulates standard file characteristics and operations.

Constructors
    TFile::TFile
        Form 1
            TFile();
        Form 2
            TFile( TFileHandle& handle, bool shouldClose);
        Form 3
            TFile( LPCTSTR name, const uint32 mode=ReadOnly|PermRead|OpenExisting );
        Description
            Form 1: Creates a TFile object with a file handle of FileNull.
            Form 2: Creates a TFile object with a file handle of handle.
            Form 3: Creates a TFile object and opens file name with the given attributes.

Public Data Members

File Flags

Member Functions

Close
    Syntax
        bool Close();
    Description
        Closes the file. Returns nonzero if successful, 0 otherwise.
GetName
    Syntax
        const string& GetName() const;
    Description
        Get file name.
Flush
    Syntax
        void Flush();
    Description
        Performs any pending I/O functions.
GetStatus
    Form 1
        bool GetStatus( TFileStatus& status ) const;
    Form 2
        bool GetStatus( LPCTSTR name, TFileStatus& status );
    Description
        Form 1: Fills status with the current file status. Returns nonzero if successful, 0 otherwise.
        Form 2: Fills status with the status for name. Returns nonzero if successful, 0 otherwise.
IsOpen
    Syntax
        int IsOpen() const;
    Description
        Returns 1 if the file is open, 0 otherwise.
Length
Length64
    Form 1
        uint32 Length() const;
    Form 2
        uint64 Length64() const;
    Form 3
        booo Length( uint32 newLen );
    Form 4
        booo Length( uint64 newLen );
    Description
        Form 1: Returns the file length.
        Form 2: Returns the file length.
        Form 3: Resizes file to newLen, return false if error.
        Form 4: Resizes file to newLen, return false if error.
LockRange
    Form 1
        void LockRange( uint32 position, uint32 count );
    Form 2
        void LockRange( uint64 position, uint64 count );
    Description
        Locks count bytes, beginning at position of the associated file.
Open
    Syntax
        bool Open( LPCTSTR name, uint32 mode=ReadOnly|PermRead|OpenExisting);
    Description
        Opens file name with the given attributes. Returns 1 if successful, 0 otherwise.
Position
Position64
    Form 1
        uint32 Position() const;
    Form 2
        uint64 Position64() const;
    Description
        Form 1: Returns the current position of the file pointer. Returns -1 to indicate an error.
        Form 2: Returns the current position of the file pointer. Returns -1 to indicate an error.
Read
    Syntax
        uint32 Read( void *buffer, uint32 numBytes );
    Description
        Reads numBytes from the file into buffer.
Seek
    Form 1
        uint32 Seek( long offset, int origin = beg );
    Form 2
        uint64 Seek( int64 offset, int origin = beg );
    Description
        Repositions the file pointer to offset bytes from the specified origin.
SeekToBegin
SeekToBegin64
    Form 1
        uint32 SeekToBegin();
    Form 2
        uint64 SeekToBegin64();
    Description
        Repositions the file pointer to the beginning of the file.
SeekToEnd
SeekToEnd64
    Form 1
        uint32 SeekToEnd();
    Form 2
        uint64 SeekToEnd64();
    Description
        Repositions the file pointer to the end of the file.
SetStatus
    Syntax
        static bool SetStatus( LPCTSTR name, const TFileStatus& status );
    Description
        Sets file name's status to status.
UnlockRange
    Form 1
        void UnlockRange(uint32 Position, uint32 count );
    Form 2
        void UnlockRange(uint64 Position, uint64 count );
    Description
        Unlocks the range at the given Position.
Write
    Syntax
        bool Write( const void *buffer, uint32 numBytes );
    Description
        Writes numbytes of buffer to the file.
ReadStruct
    Form 1
        uint32     ReadStruct(void* buffer, TBinField* fields, TByteOrderType type);
    Form 2
        static     uint32 ReadStruct(uint8* readBuf, void* buffer, TBinField* fields, TByteOrderType type);
    Description
        Form 1. Read structure from file.
        Form 2. Read structure from buffer.
WriteStruct
    Form 1
        uint32     WriteStruct(void* buffer, TBinField* fields,TByteOrderType type);
    Form 2
        static     uint32 WriteStruct(uint8* writeBuf, void* buffer, TBinField* fields, TByteOrderType type);
    Description
        Form 1. Write structure to file.
        Form 2. Read structure to buffer.
StructSize
    Syntax
        static uint32 StructSize(TBinField _OWLFAR* fields);
    Description
        Return size of structure;

Revised: February 08, 2000.


Copyright © 1998-2001 Yura Bidus. All rights reserved.