Microsoft Foundation Classes (mfc.hlp) (
Table of Contents;
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
CFile::GetStatus
◄CFile► ◄Up► ◄Contents► ◄Index► ◄Back►
──Microsoft Foundation Classes──────────────────────────────────────────────
virtual BOOL GetStatus( CFileStatus& rStatus ) const;
static BOOL GetStatus( const char* pszFileName, CFileStatus& rStatus );
Parameter Description
<rStatus> A reference to a user-supplied CFileStatus structure that
will receive the status information. The CFileStatus
structure has the following fields:
Field Meaning
CTime m_ctime The date and time the file was created
CTime m_mtime The date and time the file was last
modified
CTime m_atime The date and time the file was last
accessed for reading
LONG m_size The logical size in bytes of the file,
as reported by the MS-DOS command dir
BYTE m_attribute The MS-DOS attribute byte of the file
char m_szFullName[_MAX_PATH]
The absolute filename (_MAX_PATH is
defined in stdlib.h)
<pszFileName> A string that is the path to the desired file. The path
may be relative or absolute, but may not contain a network
name.
Remarks
The virtual version of GetStatus retrieves the status of the open file
associated with this CFile object. It does not insert a value into the
m_szFullName structure member.
The static version gets the status of the named file and copies the
filename to m_szFullName. This function obtains the file status from the
directory entry without actually opening the file. It is useful for
testing the existence and access rights of a file.
The m_attribute is the MS-DOS file attribute. The Microsoft Foundation
classes provide an enum type attribute so that you can specify
attributes symbolically:
enum Attribute {
normal = 0x00,
readOnly = 0x01,
hidden = 0x02,
system = 0x04,
volume = 0x08,
directory = 0x10,
archive = 0x20
};
Return Value
TRUE if no error, in which case <rStatus> is valid; otherwise FALSE.
FALSE indicates that the file does not exist.
Example
CFileStatus status;
extern CFile cfile;
if( cfile.GetStatus( status ) ) // virtual member function
{
#ifdef _DEBUG
afxDump << "File size = " << status.m_size << "\n";
#endif
}
char* pFileName = "test.dat";
if( CFile::GetStatus( pFileName, status ) ) // static function
{
#ifdef _DEBUG
afxDump << "Full file name = " << status.m_szFullName << "\n";
#endif
}
See Also
◄CFile::SetStatus►, ◄CTime►
-♦-