|
//
// Please do not customise this code
//
// Portions (c) Keith Westley 2000
#ifndef FILEINFO_H
#define FILEINFO_H
class CFileInfo : public CObject
{
protected:
CString _sFile;
BY_HANDLE_FILE_INFORMATION _fileInformation;
BOOL _fFileInformationValid;
BOOL _fFileExists;
CString _sPathName;
void* _pVersion;
HMODULE _hModule;
public:
CFileInfo(const CString& sFileName);
virtual ~CFileInfo(void)
{
if (_pVersion != NULL)
{
free(_pVersion);
}
}
BOOL Exists(void) const
{
return _fFileExists;
}
static CString GetHeadings(void)
{
CString sRC;
sRC = "File,Created,Modified,Version,Size,FullName,HModule";
return sRC;
}
CString GetFileDetails(void) const
{
CString sRC;
CString sSize;
sSize.Format("%lu", Size());
sRC = _sFile + "," + Created().Format("%d/%m/%Y %H:%M:%S") +
"," + LastModified().Format("%d/%m/%Y %H:%M:%S") +
"," + Version() +
"," + sSize +
"," + FullFileName() +
"," + HModuleS();
return sRC;
}
CTime LastModified(void) const
{
CTime timeRC;
if (_fFileInformationValid)
{
CTime time(_fileInformation.ftLastWriteTime);
timeRC = time;
}
return timeRC;
}
CTime LastAccessed(void) const
{
CTime timeRC;
if (_fFileInformationValid)
{
CTime time(_fileInformation.ftLastAccessTime);
timeRC = time;
}
return timeRC;
}
CTime Created(void) const
{
CTime timeRC;
if (_fFileInformationValid)
{
CTime time(_fileInformation.ftCreationTime);
timeRC = time;
}
return timeRC;
}
CString HModuleS(void) const
{
CString s;
s.Format("%lx", _hModule);
return s;
}
HMODULE HModuleH(void) const
{
return _hModule;
}
CString Version(void) const;
DWORDLONG VersionDL(void) const;
DWORDLONG SizeDWL(void) const
{
DWORDLONG dwlRC = 0;
if (_fFileInformationValid)
{
dwlRC = _fileInformation.nFileSizeHigh;
(dwlRC << 32);
dwlRC = dwlRC + _fileInformation.nFileSizeLow;
}
return dwlRC;
}
DWORD Size(void) const;
CString Directory(void) const
{
CString sRC;
if (_fFileExists)
{
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_splitpath(_sPathName, drive, dir, fname, ext);
sRC = dir;
}
return sRC;
}
CString Extension(void) const
{
CString sRC;
if (_fFileExists)
{
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_splitpath(_sPathName, drive, dir, fname, ext);
sRC = ext;
}
return sRC;
}
CString BaseFileName(void) const
{
CString sRC;
if (_fFileExists)
{
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_splitpath(_sPathName, drive, dir, fname, ext);
sRC = fname;
}
return sRC;
}
CString Drive(void) const
{
CString sRC;
if (_fFileExists)
{
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_splitpath(_sPathName, drive, dir, fname, ext);
sRC = drive;
}
return sRC;
}
DWORD Attributes(void) const
{
if (_fFileInformationValid)
{
return _fileInformation.dwFileAttributes;
}
else
{
return 0;
}
}
CString FullFileName(void) const
{
CString sRC;
if (_fFileExists)
{
sRC = _sPathName;
}
return sRC;
}
};
#endif
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.