CBS_FileSupport Class Reference

A class for general, simple file handling. More...

List of all members.

Static Public Member Functions

bool CheckDirExists (LPCTSTR lpcFileName)
bool CheckFileExists (LPCTSTR lpcFileName)
bool DoesFileExists (LPCTSTR lpcFileName, DWORD &dwFileAttribute)
bool GetFileContent (LPCTSTR lpFileName, LPTSTR &pBuf, DWORD &dwLen)
DWORD GetFileFullPathName (LPCSTR lpFileName, DWORD dwBufLen, LPSTR lpFullPath, LPSTR *lpFilePart)
DWORD GetLongPathName (LPCTSTR lpcShortPath, LPTSTR lpLongPath)
bool IsFileNameOK (LPTSTR lpFileName)
bool OverwriteFile (LPCTSTR lpFileName, LPCTSTR pBuf, DWORD dwLen)
void SetToCurrentDirectory ()
bool WriteFile (LPCTSTR lpFileName, LPCTSTR pBuf, DWORD dwLen, DWORD dwCreationDisposition)


Detailed Description

A class for general, simple file handling.

Author:
Dror Otmi
Date:
12.10.2003
Version:
V 1.0 Initial version
This class includes only static functions for simple file handling. All of the methods are static and the constructor is private so that neither an object of this class nor of a derived class could be instantiated.
The reason the methods are encapsulate in the class is mainly to avoid a name conflict with existing methods.


Member Function Documentation

bool CBS_FileSupport::CheckDirExists LPCTSTR  lpcFileName  )  [static]
 

Checks that the given directory name exists.

Parameters:
lpcFileName The directory to check.
Returns:
If the directory exists the function return 'true' otherwise 'false'.

bool CBS_FileSupport::CheckFileExists LPCTSTR  lpcFileName  )  [static]
 

Checks that the given file name exists.

Parameters:
lpcFileName The file to check.
Returns:
If the file exists (as a file NOT directory) the function return 'true' otherwise 'false'.

bool CBS_FileSupport::DoesFileExists LPCTSTR  lpcFileName,
DWORD &  dwFileAttribute
[static]
 

Checks that the given file exits.

Parameters:
lpcFileName The file to check.
dwFileAttribute The attribute to match.
Returns:
If the file exits (also as a directory) the function return 'true', otherwise 'false'.

bool CBS_FileSupport::GetFileContent LPCTSTR  lpFileName,
LPTSTR &  pBuf,
DWORD &  dwLen
[static]
 

Copy the content of a given file into a memory buffer.

Parameters:
lpFileName The name of the file.
pBuf The buffer into which the content of the file will be written.
The buffer will be ended with a null terminator character.
The buffer will be allocated on the heap using the 'new' operator. The callee is responsible to delete the buffer!!!
dwLen The number of bytes copied into pBuf not including the null terminator.
Returns:
If the functions failes, the error will be reported into the trace and the return is 'false'. otherwise the function return 'true'.

DWORD CBS_FileSupport::GetFileFullPathName LPCSTR  lpFileName,
DWORD  dwBufLen,
LPSTR  lpFullPath,
LPSTR *  lpFilePart
[static]
 

Get the full path name of a given file.

Parameters:
lpFileName The file name.
dwBufLen The size in bytes of lpFullPath.
lpFullPath The buffer where to copy the full path name.
lpFilePart A pointer only to the file name without the path, this argument might be NULL.
Returns:
The number of bytes copy to lpfullPath or zero of the file was not found.

DWORD CBS_FileSupport::GetLongPathName LPCTSTR  lpcShortPath,
LPTSTR  lpLongPath
[static]
 

Get the long path name of a given file. This function is actually implemented as standart windows API but not in Windows NT and Windows 95. To keep this copatibility we implemented it in this class.

Parameters:
lpcShortPath The short path name.
lpLongPath The long path name.
Returns:
The number of bytes copied into lpLongPath.

bool CBS_FileSupport::IsFileNameOK LPTSTR  lpFileName  )  [static]
 

Validates that a name of a file is valid.

Parameters:
lpFileName The file name to check.
Returns:
If the file name is a valid name the function will return 'true'.

bool CBS_FileSupport::OverwriteFile LPCTSTR  lpFileName,
LPCTSTR  pBuf,
DWORD  dwLen
[static]
 

Writes a content of a buffer into a file. The function calls CBS_FileSupport::WriteFile with the argument dwCreationDisposition = CREATE_ALWAYS, this means that the file will be overwritten.

Parameters:
lpFileName The name of the file.
pBuf The buffer with the data.
dwLen The length in byte of pBuf.
Returns:
If the functions failes, the error will be reported into the trace and the return is 'false'. otherwise the function return 'true'.

void CBS_FileSupport::SetToCurrentDirectory  )  [static]
 

Sets the application current directory to the directory from whiche it started. For example if the application started from the development environment, the current directory might be the Project directory and from where the application started, this might lead to failure if the application load files using relative paths.

Returns:
Nothing

bool CBS_FileSupport::WriteFile LPCTSTR  lpFileName,
LPCTSTR  pBuf,
DWORD  dwLen,
DWORD  dwCreationDisposition
[static]
 

Writes a content of a buffer into a file.

Parameters:
lpFileName The name of the file.
pBuf The buffer with the data.
dwLen The length in byte of pBuf.
dwCreationDisposition The file creation flag. For more detail see MSDN CreateFile().
Returns:
If the functions failes, the error will be reported into the trace and the return is 'false'. otherwise the function return 'true'.
Bitspot AG


Bitspot AG
Rietlistrasse 1
CH-6345 Neuheim

Bitspot AG Logo

Phone:

+41 41 755 11 22

Fax:

+41 41 755 11 31

e-mail:

mail@bitspot.com

Web:

www.bitspot.com