CWinFile Class ReferenceWindows file API wrapper.
More...
#include <WinFile.h>
Collaboration diagram for CWinFile:
[legend]List of all members.
|
Public Member Functions |
|
void | Close () |
| | Closes the file.
|
|
| CWinFile () |
| | Default constructor.
|
| | CWinFile (HANDLE hFile) |
| | Constructs a CWinFile object wrapping an existing file handle.
|
|
| ~CWinFile () |
| | Destructor.
|
| void | Attach (HANDLE hFile) |
| | Attaches to an existing file handle.
|
|
void | Detach () |
| | Detaches from file handle without closing the handle.
|
|
BOOL | IsOpen () |
| | Returns non-zero if the file is open.
|
|
HANDLE | GetHandle () |
| | Returns the curent file handle.
|
|
| operator HANDLE () |
| | Returns the curent file handle.
|
|
DWORD | Size () |
| | Returns the size of the current file in bytes.
|
| BOOL | GetPtrPos (LPDWORD ptr) |
| | Gets the current 32-bit file pointer position.
|
| BOOL | GetPtrPos (LONGLONG *ptr) |
| | Gets the current 64-bit file pointer position.
|
| LONGLONG | GetPtrPos () |
| | Returns the current 64-bit file pointer position.
|
| BOOL | SetPtrPos (LONGLONG offset, DWORD ref) |
| | Sets the 64-bit file pointer position.
|
| BOOL | SetPtrPosBegin (LONGLONG offset=0) |
| | Sets the 64-bit file pointer position relative to the beginning of the file.
|
| BOOL | SetPtrPosEnd (LONGLONG offset=0) |
| | Sets the 64-bit file pointer position relative to the end of the file.
|
| BOOL | SetPtrPosCur (LONGLONG offset=0) |
| | Sets the 64-bit file pointer position relative to the current file pointer.
|
|
BOOL | IsPath () |
| | Returns non-zero if there is a non-zero length file path.
|
| BOOL | SetPath (LPCTSTR ptr) |
| | Sets the current file path.
|
| BOOL | GetPath (LPSTR ptr) |
| | Retrieves the current file path string.
|
|
LPCTSTR | GetPath () |
| | Returns a pointer to the current file path.
|
| BOOL | SaveDWORD (DWORD dw) |
| | Writes a DWORD value into the file.
|
| BOOL | RestoreDWORD (LPDWORD pdw) |
| | Reads a DWORD value from the current file.
|
| void | SetCacheSize (DWORD read, DWORD write) |
| | Sets the size of the file cache.
|
|
void | FlushCache () |
| | Flushes the file cache.
|
| void | EnableCache (BOOL enable) |
| | Enables software file cache.
|
|
void | Flush () |
| | Flushes the Windows file buffers.
|
| BOOL | OpenTemp () |
| | Opens a temporary file.
|
| BOOL | Copy (HANDLE hFile, DWORD dwCopy, LPDWORD pdwCopied=NULL) |
| | Copies data from the specified file.
|
| BOOL | CopyFile (HANDLE hFile) |
| | Copies the entire contents of the specified file handle.
|
| BOOL | RestoreStruct (LPVOID pStruct, DWORD dwLen=0) |
| | Reads file data into a buffer pointer.
|
| BOOL | SaveStruct (LPVOID pStruct, DWORD dwLen=0) |
| | Writes data from buffer into file.
|
| virtual BOOL | Write (LPVOID pBuf, DWORD dwLen=0, LPDWORD pdwWritten=NULL, BOOL bBypassCache=FALSE) |
| | Writes data into file.
|
| virtual BOOL | Read (LPVOID pBuf, DWORD dwLen, LPDWORD pdwRead=NULL, BOOL bBypassCache=FALSE) |
| | Reads data from file.
|
| virtual BOOL | Open (LPCTSTR pFilename=NULL, DWORD access=0xffffffff) |
| | Opens the specified file.
|
| BOOL | OpenExisting (LPCTSTR pFilename=NULL, DWORD access=0xffffffff) |
| | Opens an existing file. Fails if file does not exist.
|
| BOOL | OpenNew (LPCTSTR pFilename=NULL, DWORD access=0xffffffff) |
| | Opens a new file. If file exists it is truncated.
|
| BOOL | OpenAlways (LPCTSTR pFilename=NULL, DWORD access=0xffffffff) |
| | Opens new or existing file.
|
|
void | DefaultOpenParams () |
| | Sets default file open parameters.
|
|
void | FlushWriteCache () |
| | Flushes the software write cache.
|
|
void | FlushReadCache () |
| | Flushes the software read cache.
|
| BOOL | ReadCache (LPVOID pBuffer, DWORD dwLength, LPDWORD pdwRead) |
| | Reads data from the cache.
|
| BOOL | WriteCache (LPVOID pBuffer, DWORD dwLength, LPDWORD pdwWritten) |
| | Writes data to cache.
|
Static Public Member Functions |
| static BOOL | DeleteDirectory (LPCTSTR pDir, BOOL bEmptyOnly=FALSE, BOOL bSubDirectories=TRUE, BOOL bSubDirectoriesAndFilesOnly=FALSE) |
| | Deletes the specified directory.
|
| static BOOL | CreateDirectory (LPCTSTR pDir) |
| | Creates the specified directory.
|
| static BOOL | GetSaveFileName (LPSTR pFileName, LPCTSTR pTitle=NULL, LPCTSTR pFilter=NULL, LPCTSTR pDefExt=NULL, HWND hOwner=NULL, BOOL bPreview=FALSE, DWORD dwFlags=OFN_HIDEREADONLY|OFN_PATHMUSTEXIST) |
| | Uses the windows file name dialog box to retrieve a filename.
|
| static BOOL | GetOpenFileName (LPSTR pFileName, LPCTSTR pTitle=NULL, LPCTSTR pFilter=NULL, LPCTSTR pDefExt=NULL, HWND hOwner=NULL, BOOL bPreview=FALSE, DWORD dwFlags=OFN_HIDEREADONLY|OFN_PATHMUSTEXIST, DWORD dwBufSize=CWF_STRSIZE) |
| | Uses the windows file name dialog box to retrieve a filename.
|
| static BOOL | Delete (LPCTSTR pFileName) |
| | Deletes the specified filename.
|
| static BOOL | CreateTemp (LPSTR pFileName) |
| | Creates a temporary filename.
|
| static BOOL | IsRelative (LPCTSTR pFileName) |
| | Returns non-zero if the filename contains the relative path specifiers.
|
| static LPCTSTR | WebBuildPath (LPSTR pFullPath, LPCTSTR pPath, LPCTSTR pFileName) |
| | Builds a path using the forward slash '/'.
|
| static LPCTSTR | BuildPath (LPSTR pFullPath, LPCTSTR pPath, LPCTSTR pFileName, char sep= '\\') |
| | Builds a file path.
|
| static BOOL | GetPathFromFileName (LPCTSTR pFileName, LPSTR pPath) |
| | Extracts the path from the specified filename.
|
| static void | GetFileNameFromPath (LPCTSTR pPath, LPSTR pFileName, BOOL bNoExt=FALSE) |
| | Extracts the filename from a specified file path.
|
| static BOOL | Copy (HANDLE hSource, HANDLE hTarget, DWORD dwCopy, LPDWORD pdwCopied=NULL) |
| | Copies data from one file to another.
|
| static BOOL | CopyFile (HANDLE hSource, HANDLE hTarget) |
| | Copies the entire contents of one file into another.
|
| static BOOL | VerboseCleanup (HWND hWnd=NULL, DWORD dwAttempts=5) |
| | Attempts to delete temporary directories and files.
|
| static BOOL | CreateTempDir (LPSTR pDir) |
| | Creates the named temporary directory.
|
|
static BOOL | IsTempPath () |
| | Returns non-zero if a custom temporary path is specified.
|
| static BOOL | CleanTempPath () |
| | Deletes temporary files from custom temporary path.
|
| static BOOL | DeleteTempPath () |
| | Deletes the custom temporary path and all contained files.
|
| static BOOL | SetTempPath (LPCTSTR pPath=NULL) |
| | Sets the custom temporary path.
|
|
static LPCTSTR | GetTempPath () |
| | Returns a pointer to the custom temporary path.
|
| static BOOL | DoesExist (LPCTSTR pFilename) |
| | Returns non-zero if the specified file or directory exists.
|
| static LPCTSTR | GetExtension (LPCTSTR pFile) |
| | Returns a pointer to the file extension in pFile.
|
| static BOOL | GetBrowseDir (HWND hWnd, LPCTSTR pTitle, LPSTR pDir, LPCTSTR pInit=NULL) |
| | Displays the Windows Folder picker.
|
| static int CALLBACK | BrowseCallbackProc (HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) |
| | Callback procedure used by GetBrowseDir() to set the initial folder.
|
| static BOOL | GetSpecialFolder (int nID, LPSTR buf) |
| | Returns the path to special windows folders.
|
| static int | ShowLastError (LPCTSTR pTitle, LPCTSTR pAdd=NULL, UINT type=MB_OK|MB_ICONEXCLAMATION) |
| | Displays the last Windows error returned by GetLastError().
|
| static BOOL | GetSystemErrorMsg (DWORD err, LPSTR pMsg, LPCTSTR pTemplate="Error Code: %lu\r\n%s") |
| | Returns a human readable string describing a Windows error code.
|
| static BOOL | GetDiskSpace (LPCTSTR pDrive, double *total, double *free) |
| | Returns the total disk space on the specified drive.
|
| static BOOL | CreateSizeString (LPSTR pString, double size) |
| | Creates a shortened string representing the specified quantity.
|
| static BOOL | GetCacheFileName (LPCTSTR pFilename, LPCTSTR pDir, LPSTR pCacheFilename) |
| | Generates a repeatable but indecipherable file name from pFilename.
|
| static UINT | Crc16 (BYTE b, UINT crc) |
| | Updates a 16-bit CRC.
|
| static BOOL | MatchPattern (LPCTSTR pFile, LPCTSTR pPattern) |
| | Attempts to match filename to a pattern.
|
| static BOOL | MatchPatterns (LPCTSTR pFile, LPCTSTR pPattern, char cSep= ';', BOOL bAll=FALSE) |
| | Attempts to match filename against multiple patterns.
|
| static BOOL | IsValidPathChar (BYTE ch) |
| | Returns non-zero if the character is a valid file path character.
|
| static BOOL | IsValidFileChar (BYTE ch) |
| | Returns non-zero if the character is a valid filename character.
|
| static DWORD | GetFileCount (LPCTSTR pPath, LPCTSTR pMask="*.*") |
| static BOOL | CopyFolder (LPCTSTR pSrc, LPCTSTR pDst, BOOL bSubFolders=TRUE) |
| | Copies the files in one folder to another.
|
| static BOOL | IsFile (LPCTSTR pFile) |
| | Returns non-zero if the named path is a file.
|
| static BOOL | CmpExt (LPCTSTR pFile, LPCTSTR pExt, DWORD len=3) |
| | Compares the named files extension.
|
| static LPCTSTR | GetPathElement (LPSTR pElement, LPCTSTR pPath, DWORD dwElement, LPDWORD pLeft=NULL, BOOL bReverse=FALSE) |
| | Returns the specified path element.
|
| static BOOL | Quote (LPSTR dst, LPCTSTR src=NULL, char ch= '\"', char esc = '\\' ) |
| | Quotes a given string escaping as needed.
|
| static BOOL | Unquote (LPSTR dst, LPCTSTR src=NULL, char ch= '\"', char esc = '\\' ) |
| | Unquotes a string, converting escape sequences as needed.
|
| static BOOL | ExtractResource (LPCTSTR pFile, LPCTSTR pResource, LPCTSTR pType, HMODULE hModule=NULL, BOOL bOverwrite=TRUE) |
| | Extracts resource data from the specified module to named file.
|
| static BOOL | ChangeExtension (LPSTR pFile, LPCTSTR pExt) |
| | Changes the extension of the specified file.
|
| static BOOL | GetSpecialTextName (DWORD i, LPSTR buf, DWORD size) |
| | Gets the name of specified special text.
|
| static BOOL | GetSpecialText (DWORD i, LPSTR buf, DWORD size) |
| | Gets the specified special text.
|
| static BOOL | GetSubPath (DWORD dwFolders, LPCTSTR pPath, LPSTR pSub) |
| | Gets specified depth sub path.
|
| static BOOL | GetRootPath (DWORD dwFolders, LPCTSTR pPath, LPSTR pRoot) |
| static HICON | GetIconForFile (LPCTSTR pFile, BOOL bLargeIcon=TRUE) |
| | Returns the system icon for the specified filename.
|
| static BOOL | TokenFromTextString (LPCTSTR pText, LPSTR pToken, LPDWORD pdwNext=NULL, BOOL bUseDOSCommandRules=TRUE) |
| | Grabs a token from a text string.
|
| static LPCTSTR | GetExePath (LPSTR buf, DWORD size=CWF_STRSIZE) |
| | Gets the folder path for the current application.
|
| static BOOL | GetUniqueFileName (LPSTR pUnique, LPCTSTR pFile, BOOL bNoExt=FALSE) |
| | Appends numbers to file to achieve a unique file name.
|
| static BOOL | CleanChars (LPSTR pFile) |
| | Replaces invalid file name characters with substitutes.
|
| static BOOL | CrackUrl (LPCTSTR pUrl, LPURLINFO pui) |
| | Breaks the specified URL down into it's components.
|
| static BOOL | CreateLink (LPCTSTR pPath, LPCTSTR pLink, LPCTSTR pDesc) |
| | Creates a shortcut to the specified item.
|
| static BOOL | GetMultiSelectFileName (LPCTSTR pFilenames, DWORD dwMax, LPSTR pFile, DWORD dwIndex, BYTE ucSep=0) |
| | Gets individual file names returned from multiple selected files.
|
| static BOOL | DeletePath (LPCTSTR pPath, BOOL bReboot, BOOL bEmptyOnly) |
| | Removes the specified path, can delay until reboot if in use.
|
| static BOOL | GetSpecialFolderName (int nID, LPSTR pName, LPDWORD pdwFlags=NULL, DWORD dwIndex=0, int *pnID=NULL) |
| | Gets the human readable name of a Windows special folder.
|
| static BOOL | LoadResource (LPCTSTR pResource, LPBYTE pPtr, LPDWORD pdwSize, LPCTSTR pType, HMODULE hModule=NULL) |
| | Loads a resource from the specifed module into memory.
|
| static BOOL | ValidateModuleCRC32 (HMODULE hModule=NULL, LPDWORD pCrc=NULL) |
| | Validates the CRC of the specified module.
|
| static BOOL | ValidateCRC32 (LPCTSTR pFile, LPDWORD pCrc=NULL) |
| | Validates the crc of the given file.
|
| static BOOL | AddCRC32 (LPCTSTR pFile) |
| | Calculates the CRC of a file and adds it to the end of the file.
|
| static DWORD | CRC32 (DWORD crc, LPBYTE buf, DWORD size) |
| | Updates the CRC with the specified buffer.
|
| static BOOL | ChooseColor (COLORREF *pCol, HWND hOwner=NULL, DWORD dwFlags=CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT) |
| | Shows the Windows color picker dialog box.
|
Public Attributes |
|
OPENFILEPARAMS | m_ofp |
| | File open parameters.
|
|
SECURITY_ATTRIBUTES | m_saSecurityAttributes |
| | File security attributes.
|
Static Public Attributes |
|
static DWORD | crc_table [256] |
| | Static CRC table.
|
|
static COLORREF | m_rgbCustomColors [16] |
| | Static array of custom colors used by the Windows color picker.
|
Detailed Description
Windows file API wrapper.
This class wraps the windows file API. It also provides quite a few handy static functions for file and file name manipulation.
Constructor & Destructor Documentation
| CWinFile::CWinFile |
( |
HANDLE |
hFile |
) |
[inline] |
|
|
|
Constructs a CWinFile object wrapping an existing file handle.
- Parameters:
-
| [in] | hFile | - Existing file handle |
|
Member Function Documentation
| BOOL CWinFile::AddCRC32 |
( |
LPCTSTR |
pFile |
) |
[static] |
|
|
|
Calculates the CRC of a file and adds it to the end of the file.
- Parameters:
-
| [in] | pFile | - File to update |
This function calculates the CRC for the file, then adds the CRC (four bytes) to the end of the file
- Returns:
- Non-zero if success
- See also:
|
| void CWinFile::Attach |
( |
HANDLE |
hFile |
) |
[inline] |
|
|
|
Attaches to an existing file handle.
- Parameters:
-
| [in] | hFile | - Existing file handle |
|
| int CALLBACK CWinFile::BrowseCallbackProc |
( |
HWND |
hwnd, |
|
|
UINT |
uMsg, |
|
|
LPARAM |
lParam, |
|
|
LPARAM |
lpData |
|
) |
[static] |
|
|
|
Callback procedure used by GetBrowseDir() to set the initial folder.
- Parameters:
-
| [in] | hwnd | - Handle to window |
| [in] | uMsg | - Message ID |
| [in] | lParam | - WPARAM |
| [in] | lpData | - LPARAM |
- Returns:
- Windows return code
- See also:
- GetBrowseDir()
|
| LPCTSTR CWinFile::BuildPath |
( |
LPSTR |
pFullPath, |
|
|
LPCTSTR |
pPath, |
|
|
LPCTSTR |
pFileName, |
|
|
char |
sep = '\\' |
|
) |
[static] |
|
|
|
Builds a file path.
- Parameters:
-
| [in] | pFullPath | - Receives the final filename |
| [in] | pPath | - Path |
| [in] | pFileName | - Filename |
| [in] | sep | - Path separator, Backslash is the default '\' |
The same buffer can be used for multiple parameters.
- Returns:
- Pointer in pFullPath
- See also:
|
| BOOL CWinFile::ChangeExtension |
( |
LPSTR |
pFile, |
|
|
LPCTSTR |
pExt |
|
) |
[static] |
|
|
|
Changes the extension of the specified file.
- Parameters:
-
| [in,out] | pFile | - Filename whose extension is changed |
| [in] | pExt | - New extension |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::ChooseColor |
( |
COLORREF * |
pCol, |
|
|
HWND |
hOwner = NULL, |
|
|
DWORD |
dwFlags = CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT |
|
) |
[static] |
|
|
|
Shows the Windows color picker dialog box.
- Parameters:
-
| [in,out] | pCol | - Receives the customized color |
| [in] | hOwner | - Handle to parent window |
| [in] | dwFlags | - Color dialog box flags |
- Returns:
- Non-zero if a new color is chosen.
- See also:
|
| BOOL CWinFile::CleanChars |
( |
LPSTR |
pFile |
) |
[static] |
|
|
|
Replaces invalid file name characters with substitutes.
- Parameters:
-
| [in] | pFile | - Filename to clean |
char szPath[ 256 ] = "This ? file | name < contains > illegal * characters.txt";
CleanChars( szPath );
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::CleanTempPath |
( |
|
) |
[static] |
|
|
|
Deletes temporary files from custom temporary path.
- Returns:
- Non-zero if files are deleted
|
| BOOL CWinFile::CmpExt |
( |
LPCTSTR |
pFile, |
|
|
LPCTSTR |
pExt, |
|
|
DWORD |
len = 3 |
|
) |
[static] |
|
|
|
Compares the named files extension.
- Parameters:
-
| [in] | pFile | - Filename |
| [in] | pExt | - Extension |
| [in] | len | - Number of bytes in pExt to compare |
Example: if ( CmpExt( "Airplane.jpg", "jpg" ) )
;
- Returns:
- Non-zero if match
- See also:
|
| BOOL CWinFile::Copy |
( |
HANDLE |
hSource, |
|
|
HANDLE |
hTarget, |
|
|
DWORD |
dwCopy, |
|
|
LPDWORD |
pdwCopied = NULL |
|
) |
[static] |
|
|
|
Copies data from one file to another.
- Parameters:
-
| [in] | hSource | - Source file handle |
| [out] | hTarget | - Destination file handle |
| [in] | dwCopy | - Number of bytes to copy |
| [out] | pdwCopied | - Number of bytes actually copied |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::Copy |
( |
HANDLE |
hFile, |
|
|
DWORD |
dwCopy, |
|
|
LPDWORD |
pdwCopied = NULL |
|
) |
|
|
|
|
Copies data from the specified file.
- Parameters:
-
| [in] | hFile | - Handle to open file |
| [in] | dwCopy | - Number of bytes to copy |
| [out] | pdwCopied | - Number of bytes actually copied |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::CopyFile |
( |
HANDLE |
hSource, |
|
|
HANDLE |
hTarget |
|
) |
[static] |
|
|
|
Copies the entire contents of one file into another.
- Parameters:
-
| [in] | hSource | - Source file handle |
| [out] | hTarget | - Target file handle |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::CopyFile |
( |
HANDLE |
hFile |
) |
|
|
|
|
Copies the entire contents of the specified file handle.
- Parameters:
-
| [in] | hFile | - Handle to open file |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::CopyFolder |
( |
LPCTSTR |
pSrc, |
|
|
LPCTSTR |
pDst, |
|
|
BOOL |
bSubFolders = TRUE |
|
) |
[static] |
|
|
|
Copies the files in one folder to another.
- Parameters:
-
| [in] | pSrc | - Source folder name |
| [in] | pDst | - Destination folder name |
| [in] | bSubFolders | - Non-zero to copy sub folders |
- Returns:
- Non-zero if files are copied
- See also:
|
| BOOL CWinFile::CrackUrl |
( |
LPCTSTR |
pUrl, |
|
|
LPURLINFO |
pui |
|
) |
[static] |
|
|
|
Breaks the specified URL down into it's components.
- Parameters:
-
| [in] | pUrl | - URL to decompose |
| [in] | pui | - Structure containing URL components |
- Returns:
- Non-zero if success
- See also:
|
| static UINT CWinFile::Crc16 |
( |
BYTE |
b, |
|
|
UINT |
crc |
|
) |
[inline, static] |
|
|
|
Updates a 16-bit CRC.
- Parameters:
-
| [in] | b | - Source byte for updating |
| [in] | crc | - Current CRC |
- Returns:
- New CRC
- See also:
|
| DWORD CWinFile::CRC32 |
( |
DWORD |
crc, |
|
|
LPBYTE |
buf, |
|
|
DWORD |
size |
|
) |
[static] |
|
|
|
Updates the CRC with the specified buffer.
- Parameters:
-
| [in] | crc | - Initial CRC value |
| [in] | buf | - Pointer to input buffer |
| [in] | size | - Number of bytes in buf |
- Returns:
- Updated CRC value
- See also:
|
| BOOL CWinFile::CreateDirectory |
( |
LPCTSTR |
pDir |
) |
[static] |
|
|
|
Creates the specified directory.
- Parameters:
-
| [in] | pDir | - Directory to create |
This can create any number of nested directories.
- Returns:
- See also:
|
| BOOL CWinFile::CreateLink |
( |
LPCTSTR |
pPath, |
|
|
LPCTSTR |
pLink, |
|
|
LPCTSTR |
pDesc |
|
) |
[static] |
|
|
|
Creates a shortcut to the specified item.
- Parameters:
-
| [in] | pPath | - Path to file object |
| [in] | pLink | - Shortcut path |
| [in] | pDesc | - Description for shortcut |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::CreateSizeString |
( |
LPSTR |
pString, |
|
|
double |
size |
|
) |
[static] |
|
|
|
Creates a shortened string representing the specified quantity.
- Parameters:
-
| [out] | pString | - Receives the shortened string |
| [in] | size | - Value to convert |
Example returned strings:
- 1.32 MB
- 345 KB
- 534.3 GB
- 600 TB
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::CreateTemp |
( |
LPSTR |
pFileName |
) |
[static] |
|
|
|
Creates a temporary filename.
- Parameters:
-
| [in] | pFileName | - Receives the temporary filename |
This function uses the Windows temporary directory unless another directory is specified via SetTempPath(). If the temporary folder does not exist, it is created. This function does not create the named file.
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::CreateTempDir |
( |
LPSTR |
pDir |
) |
[static] |
|
|
|
Creates the named temporary directory.
- Parameters:
-
| [in] | pDir | - Temporary directory |
This directory will be used to hold temporary files. It will also be the target of a cleanup.
- Returns:
- Non-zero if directory is created or already exists.
- See also:
|
| static BOOL CWinFile::Delete |
( |
LPCTSTR |
pFileName |
) |
[inline, static] |
|
|
|
Deletes the specified filename.
- Parameters:
-
| [in] | pFileName | - Filename to delete |
- Returns:
- Non-zero if file was deleted
- See also:
|
| BOOL CWinFile::DeleteDirectory |
( |
LPCTSTR |
pDir, |
|
|
BOOL |
bEmptyOnly = FALSE, |
|
|
BOOL |
bSubDirectories = TRUE, |
|
|
BOOL |
bSubDirectoriesAndFilesOnly = FALSE |
|
) |
[static] |
|
|
|
Deletes the specified directory.
- Parameters:
-
| [in] | pDir | - Directory to delete |
| [in] | bEmptyOnly | - Non-zero to delete only the contents of the specified directory. |
| [in] | bSubDirectories | - Non-zero to delete the sub all sub directories. |
| [in] | bSubDirectoriesAndFilesOnly | - Deletes only sub directories. That is, it does not delete files in the specified directories. |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::DeletePath |
( |
LPCTSTR |
pPath, |
|
|
BOOL |
bReboot, |
|
|
BOOL |
bEmptyOnly |
|
) |
[static] |
|
|
|
Removes the specified path, can delay until reboot if in use.
- Parameters:
-
| [in] | pPath | - Path to folder or file to delete |
| [in] | bReboot | - If non-zero, and pPath is in use, pPath is deleted at the next system reboot. |
| [in] | bEmptyOnly | - Deletes the named path only if it is empty. |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::DeleteTempPath |
( |
|
) |
[static] |
|
|
|
Deletes the custom temporary path and all contained files.
- Returns:
- Non-zero if deleted
|
| BOOL CWinFile::DoesExist |
( |
LPCTSTR |
pFilename |
) |
[static] |
|
|
|
Returns non-zero if the specified file or directory exists.
- Parameters:
-
| [in] | pFilename | - Filename |
- Returns:
- non-zero if file or directory exists
- See also:
|
| void CWinFile::EnableCache |
( |
BOOL |
enable |
) |
[inline] |
|
|
|
Enables software file cache.
- Parameters:
-
| [in] | enable | - Non-zero to enable the file cache |
|
| BOOL CWinFile::ExtractResource |
( |
LPCTSTR |
pFile, |
|
|
LPCTSTR |
pResource, |
|
|
LPCTSTR |
pType, |
|
|
HMODULE |
hModule = NULL, |
|
|
BOOL |
bOverwrite = TRUE |
|
) |
[static] |
|
|
|
Extracts resource data from the specified module to named file.
- Parameters:
-
| [in] | pFile | - Module filename |
| [in] | pResource | - Resource name |
| [in] | pType | - Resource type |
| [in] | hModule | - Module handle |
| [in] | bOverwrite | - Non-zero to overwrite existing file |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::GetBrowseDir |
( |
HWND |
hWnd, |
|
|
LPCTSTR |
pTitle, |
|
|
LPSTR |
pDir, |
|
|
LPCTSTR |
pInit = NULL |
|
) |
[static] |
|
|
|
Displays the Windows Folder picker.
- Parameters:
-
| [in] | hWnd | - Handle to parent window |
| [in] | pTitle | - Title for picker window |
| [out] | pDir | - Receives the folder name |
| [in] | pInit | - Initial folder, can be NULL |
- Returns:
- Non-zero if a folder is selected
- See also:
|
| BOOL CWinFile::GetCacheFileName |
( |
LPCTSTR |
pFilename, |
|
|
LPCTSTR |
pDir, |
|
|
LPSTR |
pCacheFilename |
|
) |
[static] |
|
|
|
Generates a repeatable but indecipherable file name from pFilename.
- Parameters:
-
| [in] | pFilename | - Filename |
| [in] | pDir | - Direcory name |
| [out] | pCacheFilename | - Receives the encoded file name |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::GetDiskSpace |
( |
LPCTSTR |
pDrive, |
|
|
double * |
total, |
|
|
double * |
free |
|
) |
[static] |
|
|
|
Returns the total disk space on the specified drive.
- Parameters:
-
| [in] | pDrive | - Drive to query |
| [out] | total | - Receives the total disk space |
| [out] | free | - Receives the free disk space |
- Returns:
- Non-zero if success
- See also:
|
| LPCTSTR CWinFile::GetExePath |
( |
LPSTR |
buf, |
|
|
DWORD |
size = CWF_STRSIZE |
|
) |
[static] |
|
|
|
Gets the folder path for the current application.
- Parameters:
-
| [in] | buf | - Receives application folder |
| [in] | size | - Size of buffer in buf |
If the application path is "c:/myprogram/myapp.exe"
This function returns "c:/myprogram"
- Returns:
- Pointer in buf
- See also:
|
| LPCTSTR CWinFile::GetExtension |
( |
LPCTSTR |
pFile |
) |
[static] |
|
|
|
Returns a pointer to the file extension in pFile.
- Parameters:
-
The returned pointer is actually an offset into pFile.
- Returns:
- Pointer to extension if found, otherwise NULL
- See also:
|
| DWORD CWinFile::GetFileCount |
( |
LPCTSTR |
pPath, |
|
|
LPCTSTR |
pMask = "*.*" |
|
) |
[static] |
|
|
|
- Parameters:
-
- Returns:
- See also:
|
| void CWinFile::GetFileNameFromPath |
( |
LPCTSTR |
pPath, |
|
|
LPSTR |
pFileName, |
|
|
BOOL |
bNoExt = FALSE |
|
) |
[static] |
|
|
|
Extracts the filename from a specified file path.
- Parameters:
-
| [in] | pPath | - The full path to file |
| [out] | pFileName | - Receives the extracted path |
| [in] | bNoExt | - If non-zero, the extension is stripped from the filename. |
|
| HICON CWinFile::GetIconForFile |
( |
LPCTSTR |
pFile, |
|
|
BOOL |
bLargeIcon = TRUE |
|
) |
[static] |
|
|
|
Returns the system icon for the specified filename.
- Parameters:
-
| [in] | pFile | - Filename |
| [in] | bLargeIcon | - Non-zero for large icon, zero for small icon. |
Creates copy of the system icon. When the icon is no longer needed, delete it with DestroyIcon().
- Returns:
- Handle to system icon for file
- See also:
|
| BOOL CWinFile::GetMultiSelectFileName |
( |
LPCTSTR |
pFilenames, |
|
|
DWORD |
dwMax, |
|
|
LPSTR |
pFile, |
|
|
DWORD |
dwIndex, |
|
|
BYTE |
ucSep = 0 |
|
) |
[static] |
|
|
|
Gets individual file names returned from multiple selected files.
- Parameters:
-
| [in] | pFilenames | - Multiple file names |
| [in] | dwMax | - Size of buffer in pFilenames |
| [out] | pFile | - Receives full path to single file |
| [in] | dwIndex | - Index of the file to return |
| [in] | ucSep | - Separator between file names |
The GetSaveFileName() and GetOpenFileName() functions can return multiple files. This allows you to build the complete path for each file.
To get each file, call this function incrementing dwIndex each time until it returns false.
- Returns:
- Non-zero if valid file name is returned
- See also:
|
| BOOL CWinFile::GetOpenFileName |
( |
LPSTR |
pFileName, |
|
|
LPCTSTR |
pTitle = NULL, |
|
|
LPCTSTR |
pFilter = NULL, |
|
|
LPCTSTR |
pDefExt = NULL, |
|
|
HWND |
hOwner = NULL, |
|
|
BOOL |
bPreview = FALSE, |
|
|
DWORD |
dwFlags = OFN_HIDEREADONLY|OFN_PATHMUSTEXIST, |
|
|
DWORD |
dwBufSize = CWF_STRSIZE |
|
) |
[static] |
|
|
|
Uses the windows file name dialog box to retrieve a filename.
- Parameters:
-
| [in] | pFileName | - Receives the filename |
| [in] | pTitle | - Title for dialog box |
| [in] | pFilter | - File type filters |
| [in] | pDefExt | - Default extension |
| [in] | hOwner | - Handle to parent window |
| [in] | bPreview | - Non-zero for integrated file preview |
| [in] | dwFlags | - Optional file flags |
| [in] | dwBufSize | - Size of buffer in pFileName |
Example:
char szImage[ MAX_PATH ] = ""; BOOL bImageFileChoosen = GetOpenFileName( szImage, "Save image capture", "Joint Photographic Experts Group (*.jpg)\x0*.jpg\x0" "Portable Network Graphic (*.png)\x0*.png\x0" "Windows bitmap (*.bmp)\x0*.bmp\x0", "jpg", GetSafeHwnd() );
- Returns:
- Non-zero if a file was selected, otherwise zero
- See also:
|
| BOOL CWinFile::GetPath |
( |
LPSTR |
ptr |
) |
[inline] |
|
|
|
Retrieves the current file path string.
- Parameters:
-
| [in] | ptr | - Buffer that receives the file path string |
- Returns:
- Non-zero if success
- See also:
|
| LPCTSTR CWinFile::GetPathElement |
( |
LPSTR |
pElement, |
|
|
LPCTSTR |
pPath, |
|
|
DWORD |
dwElement, |
|
|
LPDWORD |
pLeft = NULL, |
|
|
BOOL |
bReverse = FALSE |
|
) |
[static] |
|
|
|
Returns the specified path element.
- Parameters:
-
| [out] | pElement | - Receives the element |
| [in] | pPath | - Path to analyze |
| [in] | dwElement | - Index of the element |
| [out] | pLeft | - Number of elements remaining |
| [in] | bReverse | - Reverse index direction |
Examples:
- Returns:
- See also:
|
| BOOL CWinFile::GetPathFromFileName |
( |
LPCTSTR |
pFileName, |
|
|
LPSTR |
pPath |
|
) |
[static] |
|
|
|
Extracts the path from the specified filename.
- Parameters:
-
| [in] | pFileName | - Full path to file |
| [out] | pPath | - Receives xtracted path |
- Returns:
- Non-zero if a path was extracted.
- See also:
|
| LONGLONG CWinFile::GetPtrPos |
( |
|
) |
|
|
|
|
Returns the current 64-bit file pointer position.
- Returns:
- 64-bit file pointer position
- See also:
|
| BOOL CWinFile::GetPtrPos |
( |
LONGLONG * |
ptr |
) |
|
|
|
|
Gets the current 64-bit file pointer position.
- Parameters:
-
| [in] | ptr | - Receives the current file pointer position |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::GetPtrPos |
( |
LPDWORD |
ptr |
) |
|
|
|
|
Gets the current 32-bit file pointer position.
- Parameters:
-
| [in] | ptr | - Receives the current file pointer position |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::GetRootPath |
( |
DWORD |
dwFolders, |
|
|
LPCTSTR |
pPath, |
|
|
LPSTR |
pRoot |
|
) |
[static] |
|
|
|
- Parameters:
-
| [in] | dwFolders | - Depth to retreive |
| [in] | pPath | - Source path |
| [out] | pRoot | - Receives root path |
Example:
char szPath[ 256 ];
GetSubPath( 2, "C:\\one\\two\\three", szPath );
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::GetSaveFileName |
( |
LPSTR |
pFileName, |
|
|
LPCTSTR |
pTitle = NULL, |
|
|
LPCTSTR |
pFilter = NULL, |
|
|
LPCTSTR |
pDefExt = NULL, |
|
|
HWND |
hOwner = NULL, |
|
|
BOOL |
bPreview = FALSE, |
|
|
DWORD |
dwFlags = OFN_HIDEREADONLY|OFN_PATHMUSTEXIST |
|
) |
[static] |
|
|
|
Uses the windows file name dialog box to retrieve a filename.
- Parameters:
-
| [in] | pFileName | - Receives the filename |
| [in] | pTitle | - Title for dialog box |
| [in] | pFilter | - File type filters |
| [in] | pDefExt | - Default extension |
| [in] | hOwner | - Handle to parent window |
| [in] | bPreview | - Non-zero for integrated file preview |
| [in] | dwFlags | - Optional file flags |
Example:
char szImage[ MAX_PATH ] = ""; BOOL bImageFileChoosen = GetSaveFileName( szImage, "Save image capture", "Joint Photographic Experts Group (*.jpg)\x0*.jpg\x0" "Portable Network Graphic (*.png)\x0*.png\x0" "Windows bitmap (*.bmp)\x0*.bmp\x0", "jpg", GetSafeHwnd() );
- Returns:
- Non-zero if a file was selected, otherwise zero
- See also:
|
| BOOL CWinFile::GetSpecialFolder |
( |
int |
nID, |
|
|
LPSTR |
buf |
|
) |
[static] |
|
|
|
Returns the path to special windows folders.
- Parameters:
-
| [in] | nID | - Special folder ID |
| [out] | buf | - Receives the path to the specified folder |
Codes with possible example folders...
Extra folders
- CSIDL_USER_SYSTEM - System 32 folder
- CSIDL_USER_WINDOWS - Windows folder
- CSIDL_USER_TEMP - Windows temporary directory
- CSIDL_USER_CURRENT - Current folder
- CSIDL_USER_DEFDRIVE - Drive that windows is installed on.
Default folders
- CSIDL_ALTSTARTUP - File system directory that corresponds to the user's nonlocalized Startup program group.
- CSIDL_APPDATA - File system directory that serves as a common repository for application-specific data.
- CSIDL_BITBUCKET - File system directory containing file objects in the user's Recycle Bin. The location of this directory is not in the registry; it is marked with the hidden and system attributes to prevent the user from moving or deleting it.
- CSIDL_COMMON_ALTSTARTUP - File system directory that corresponds to the nonlocalized Startup program group for all users.
- CSIDL_COMMON_DESKTOPDIRECTORY - File system directory that contains files and folders that appear on the desktop for all users.
- CSIDL_COMMON_FAVORITES - File system directory that serves as a common repository for all users' favorite items.
- CSIDL_COMMON_PROGRAMS - File system directory that contains the directories for the common program groups that appear on the Start menu for all users.
- CSIDL_COMMON_STARTMENU - File system directory that contains the programs and folders that appear on the Start menu for all users.
- CSIDL_COMMON_STARTUP - File system directory that contains the programs that appear in the Startup folder for all users.
- CSIDL_CONTROLS - Virtual folder containing icons for the Control Panel applications.
- CSIDL_COOKIES - File system directory that serves as a common repository for Internet cookies.
- CSIDL_DESKTOP - Windows Desktop—virtual folder at the root of the namespace.
- CSIDL_DESKTOPDIRECTORY - File system directory used to physically store file objects on the desktop (not to be confused with the desktop folder itself).
- CSIDL_DRIVES - My Computer—virtual folder containing everything on the local computer: storage devices, printers, and Control Panel. The folder may also contain mapped network drives.
- CSIDL_FAVORITES - File system directory that serves as a common repository for the user's favorite items.
- CSIDL_FONTS - Virtual folder containing fonts.
- CSIDL_HISTORY - File system directory that serves as a common repository for Internet history items.
- CSIDL_INTERNET - Virtual folder representing the Internet.
- CSIDL_INTERNET_CACHE - File system directory that serves as a common repository for temporary Internet files.
- CSIDL_NETHOOD - File system directory containing objects that appear in the network neighborhood.
- CSIDL_NETWORK - Network Neighborhood Folder—virtual folder representing the top level of the network hierarchy.
- CSIDL_PERSONAL - File system directory that serves as a common repository for documents.
- CSIDL_PRINTERS - Virtual folder containing installed printers.
- CSIDL_PRINTHOOD - File system directory that serves as a common repository for printer links.
- CSIDL_PROGRAMS - File system directory that contains the user's program groups (which are also file system directories).
- CSIDL_RECENT - File system directory that contains the user's most recently used documents.
- CSIDL_SENDTO - File system directory that contains Send To menu items.
- CSIDL_STARTMENU - File system directory containing Start menu items.
- CSIDL_STARTUP - File system directory that corresponds to the user's Startup program group. The system starts these programs whenever any user logs onto Windows NT or starts Windows 95.
- CSIDL_TEMPLATES - File system directory that serves as a common repository for document templates.
- Returns:
- Non-zero if valid folder is returned.
- See also:
|
| BOOL CWinFile::GetSpecialFolderName |
( |
int |
nID, |
|
|
LPSTR |
pName, |
|
|
LPDWORD |
pdwFlags = NULL, |
|
|
DWORD |
dwIndex = 0, |
|
|
int * |
pnID = NULL |
|
) |
[static] |
|
|
|
Gets the human readable name of a Windows special folder.
- Parameters:
-
| [in] | nID | - Special folder ID |
| [out] | pName | - Receives the name of the special folder |
| [in] | pdwFlags | - Special folder flags |
| [in] | dwIndex | - One-based index of special folder to retrieve. |
| [in] | pnID | - Receives the special folder ID of dwIndex |
This function provides a way to get the special folder name, as well as functionality for enumerating all folder types
Getting a special folder name
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::GetSpecialText |
( |
DWORD |
i, |
|
|
LPSTR |
buf, |
|
|
DWORD |
size |
|
) |
[static] |
|
|
|
Gets the specified special text.
- Parameters:
-
| [in] | i | - Index of special text |
| [out] | buf | - Receives special text |
| [in] | size | - Size of buffer in buf |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::GetSpecialTextName |
( |
DWORD |
i, |
|
|
LPSTR |
buf, |
|
|
DWORD |
size |
|
) |
[static] |
|
|
|
Gets the name of specified special text.
- Parameters:
-
| [in] | i | - Index of special text |
| [out] | buf | - Receives special text name |
| [in] | size | - Size of buffer in buf |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::GetSubPath |
( |
DWORD |
dwFolders, |
|
|
LPCTSTR |
pPath, |
|
|
LPSTR |
pSub |
|
) |
[static] |
|
|
|
Gets specified depth sub path.
- Parameters:
-
| [in] | dwFolders | - Depth to retreive |
| [in] | pPath | - Source path |
| [out] | pSub | - Receives sub path |
Example:
char szPath[ 256 ];
GetSubPath( 2, "C:\\one\\two\\three", szPath );
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::GetSystemErrorMsg |
( |
DWORD |
err, |
|
|
LPSTR |
pMsg, |
|
|
LPCTSTR |
pTemplate = "Error Code: %lu\r\n%s" |
|
) |
[static] |
|
|
|
Returns a human readable string describing a Windows error code.
- Parameters:
-
| [in] | err | - Windows error code |
| [out] | pMsg | - Receives the error string |
| [in] | pTemplate | - Defines the format of the returned string |
- Returns:
- Non-zero if err is a valid Windows error code
- See also:
|
| BOOL CWinFile::GetUniqueFileName |
( |
LPSTR |
pUnique, |
|
|
LPCTSTR |
pFile, |
|
|
BOOL |
bNoExt = FALSE |
|
) |
[static] |
|
|
|
Appends numbers to file to achieve a unique file name.
- Parameters:
-
| [out] | pUnique | - Receives unique file name |
| [in] | pFile | - Filename |
| [in] | bNoExt | - Set to non-zero to strip the extension |
Example:
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::IsFile |
( |
LPCTSTR |
pFile |
) |
[static] |
|
|
|
Returns non-zero if the named path is a file.
- Parameters:
-
This function returns zero if the named path is a directory.
- Returns:
- Non-zero if the named path is a file
- See also:
|
| BOOL CWinFile::IsRelative |
( |
LPCTSTR |
pFileName |
) |
[static] |
|
|
|
Returns non-zero if the filename contains the relative path specifiers.
- Parameters:
-
| [in] | pFileName | - Filename |
|
| BOOL CWinFile::IsValidFileChar |
( |
BYTE |
ch |
) |
[static] |
|
|
|
Returns non-zero if the character is a valid filename character.
- Parameters:
-
| [in] | ch | - Character to test |
This function returns zero if the character cannot be used in a Windows filename.
- Returns:
- Non-zero if ch is a valid filename character.
- See also:
|
| BOOL CWinFile::IsValidPathChar |
( |
BYTE |
ch |
) |
[static] |
|
|
|
Returns non-zero if the character is a valid file path character.
- Parameters:
-
| [in] | ch | - Character to test |
This function returns zero if the character cannot be used in a Windows file path.
- Returns:
- Non-zero if ch is a valid file path character.
- See also:
|
| BOOL CWinFile::LoadResource |
( |
LPCTSTR |
pResource, |
|
|
LPBYTE |
pPtr, |
|
|
LPDWORD |
pdwSize, |
|
|
LPCTSTR |
pType, |
|
|
HMODULE |
hModule = NULL |
|
) |
[static] |
|
|
|
Loads a resource from the specifed module into memory.
- Parameters:
-
| [in] | pResource | - Resource name |
| [out] | pPtr | - Receives the resource data |
| [out] | pdwSize | - Receives the number of bytes copied to pPtr |
| [in] | pType | - Resource type |
| [in] | hModule | - Handle to module containing resource |
Call with pPtr set to NULL to receive the required buffer length in pdwSize.
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::MatchPattern |
( |
LPCTSTR |
pFile, |
|
|
LPCTSTR |
pPattern |
|
) |
[static] |
|
|
|
Attempts to match filename to a pattern.
- Parameters:
-
| [in] | pFile | - Filename |
| [in] | pPattern | - Pattern for matching |
Uses standard wild card characters
Example patterns:
- *.*
- *.jpg
- Backup???.bak
- C:\html_files\Bob*.htm
- Returns:
- Non-zero if filename matches the pattern
- See also:
|
| BOOL CWinFile::MatchPatterns |
( |
LPCTSTR |
pFile, |
|
|
LPCTSTR |
pPattern, |
|
|
char |
cSep = ';', |
|
|
BOOL |
bAll = FALSE |
|
) |
[static] |
|
|
|
Attempts to match filename against multiple patterns.
- Parameters:
-
| [in] | pFile | - Filename |
| [in] | pPattern | - Pattern for matching |
| [in] | cSep | - Character separating patterns. Defaults to ';' |
| [in] | bAll | - If non-zero, filename must match ALL patterns. |
Uses standard wild card characters
Example patterns:
- *.*
- *.jpg
- Backup???.bak
- C:\html_files\Bob*.htm
- Returns:
- If bAll is zero, returns non-zero if the filename matches any of the patterns. If bAll is non-zero, returns non-zero if the filename matches all of the patterns.
- See also:
|
| BOOL CWinFile::Open |
( |
LPCTSTR |
pFilename = NULL, |
|
|
DWORD |
access = 0xffffffff |
|
) |
[virtual] |
|
|
|
Opens the specified file.
- Parameters:
-
| [in] | pFilename | - Filename to open |
| [in] | access | - Desired access, 0xffffffff for default access. |
- Returns:
- Non-zero if file is opened
- See also:
|
| BOOL CWinFile::OpenAlways |
( |
LPCTSTR |
pFilename = NULL, |
|
|
DWORD |
access = 0xffffffff |
|
) |
|
|
|
|
Opens new or existing file.
- Parameters:
-
| [in] | pFilename | - Filename to open |
| [in] | access | - Desired access, 0xffffffff for default access. |
If the file does not exist it is created. If the file exists, it is opened and the file pointer is set to the end of the file.
- Returns:
- Non-zero if a file is opened.
- See also:
|
| BOOL CWinFile::OpenExisting |
( |
LPCTSTR |
pFilename = NULL, |
|
|
DWORD |
access = 0xffffffff |
|
) |
|
|
|
|
Opens an existing file. Fails if file does not exist.
- Parameters:
-
| [in] | pFilename | - Filename to open |
| [in] | access | - Desired access, 0xffffffff for default access. |
- Returns:
- Non-zero if a file is opened.
- See also:
|
| BOOL CWinFile::OpenNew |
( |
LPCTSTR |
pFilename = NULL, |
|
|
DWORD |
access = 0xffffffff |
|
) |
|
|
|
|
Opens a new file. If file exists it is truncated.
- Parameters:
-
| [in] | pFilename | - Filename to open |
| [in] | access | - Desired access, 0xffffffff for default access. |
- Returns:
- Non-zero if a file is opened.
- See also:
|
| BOOL CWinFile::OpenTemp |
( |
|
) |
|
|
|
|
Opens a temporary file.
- Returns:
- Non-zero if temporary file is opened.
- See also:
|
| BOOL CWinFile::Quote |
( |
LPSTR |
dst, |
|
|
LPCTSTR |
src = NULL, |
|
|
char |
ch = '\"', |
|
|
char |
esc = '\\' |
|
) |
[static] |
|
|
|
Quotes a given string escaping as needed.
- Parameters:
-
| [out] | dst | - Receives quoted string |
| [in] | src | - Unquoted string |
| [in] | ch | - Quote character |
| [in] | esc | - Escape character |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::Read |
( |
LPVOID |
pBuf, |
|
|
DWORD |
dwLen, |
|
|
LPDWORD |
pdwRead = NULL, |
|
|
BOOL |
bBypassCache = FALSE |
|
) |
[virtual] |
|
|
|
Reads data from file.
- Parameters:
-
| [out] | pBuf | - Receives data read from file |
| [in] | dwLen | - Size of buffer in pBuf |
| [out] | pdwRead | - Receives number of bytes read |
| [in] | bBypassCache | - Non-zero to bypass disk cache |
- Returns:
- See also:
|
| BOOL CWinFile::ReadCache |
( |
LPVOID |
pBuffer, |
|
|
DWORD |
dwLength, |
|
|
LPDWORD |
pdwRead |
|
) |
|
|
|
|
Reads data from the cache.
- Parameters:
-
| [out] | pBuffer | - Receives data |
| [in] | dwLength | - Length of buffer in pBuffer |
| [out] | pdwRead | - Number of bytes read |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::RestoreDWORD |
( |
LPDWORD |
pdw |
) |
[inline] |
|
|
|
Reads a DWORD value from the current file.
- Parameters:
-
| [in] | pdw | - Recieves the DWORD value |
- Returns:
- See also:
|
| BOOL CWinFile::RestoreStruct |
( |
LPVOID |
pStruct, |
|
|
DWORD |
dwLen = 0 |
|
) |
|
|
|
|
Reads file data into a buffer pointer.
- Parameters:
-
| [out] | pStruct | - Receives file data |
| [in] | dwLen | - Number of bytes to copy |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::SaveDWORD |
( |
DWORD |
dw |
) |
[inline] |
|
|
|
Writes a DWORD value into the file.
- Parameters:
-
| [in] | dw | - DWORD value to write |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::SaveStruct |
( |
LPVOID |
pStruct, |
|
|
DWORD |
dwLen = 0 |
|
) |
|
|
|
|
Writes data from buffer into file.
- Parameters:
-
| [in] | pStruct | - Pointer to data |
| [in] | dwLen | - Number of bytes to copy from pStruct |
- Returns:
- See also:
|
| void CWinFile::SetCacheSize |
( |
DWORD |
read, |
|
|
DWORD |
write |
|
) |
[inline] |
|
|
|
Sets the size of the file cache.
- Parameters:
-
| [in] | read | - Read cache size |
| [in] | write | - Write cache size |
|
| BOOL CWinFile::SetPath |
( |
LPCTSTR |
ptr |
) |
[inline] |
|
|
|
Sets the current file path.
- Parameters:
-
| [in] | ptr | - Pointer to file path string |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::SetPtrPos |
( |
LONGLONG |
offset, |
|
|
DWORD |
ref |
|
) |
[inline] |
|
|
|
Sets the 64-bit file pointer position.
- Parameters:
-
| [in] | offset | - 64-bit file offset pointer |
| [in] | ref | - Relative specifier for offset |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::SetPtrPosBegin |
( |
LONGLONG |
offset = 0 |
) |
[inline] |
|
|
|
Sets the 64-bit file pointer position relative to the beginning of the file.
- Parameters:
-
| [in] | offset | - 64-bit file offset pointer |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::SetPtrPosCur |
( |
LONGLONG |
offset = 0 |
) |
[inline] |
|
|
|
Sets the 64-bit file pointer position relative to the current file pointer.
- Parameters:
-
| [in] | offset | - 64-bit file offset pointer |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::SetPtrPosEnd |
( |
LONGLONG |
offset = 0 |
) |
[inline] |
|
|
|
Sets the 64-bit file pointer position relative to the end of the file.
- Parameters:
-
| [in] | offset | - 64-bit file offset pointer |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::SetTempPath |
( |
LPCTSTR |
pPath = NULL |
) |
[static] |
|
|
|
Sets the custom temporary path.
- Parameters:
-
| [in] | pPath | - Temporary path |
- Returns:
- Non-zero if success
- See also:
|
| int CWinFile::ShowLastError |
( |
LPCTSTR |
pTitle, |
|
|
LPCTSTR |
pAdd = NULL, |
|
|
UINT |
type = MB_OK|MB_ICONEXCLAMATION |
|
) |
[static] |
|
|
|
Displays the last Windows error returned by GetLastError().
- Parameters:
-
| [in] | pTitle | - Title for the dialog box. |
| [in] | pAdd | - String to add to end of error |
| [in] | type | - Dialog box type |
- Returns:
- Return code from dialog box
- See also:
|
| BOOL CWinFile::TokenFromTextString |
( |
LPCTSTR |
pText, |
|
|
LPSTR |
pToken, |
|
|
LPDWORD |
pdwNext = NULL, |
|
|
BOOL |
bUseDOSCommandRules = TRUE |
|
) |
[static] |
|
|
|
Grabs a token from a text string.
- Parameters:
-
| [in] | pText | - Text string |
| [out] | pToken | - Receives token |
| [in] | pdwNext | - Offset to next token |
| [in] | bUseDOSCommandRules | - Non zero to use DOS command line rules. |
- Returns:
- Non-zero if token is copied
- See also:
|
| BOOL CWinFile::Unquote |
( |
LPSTR |
dst, |
|
|
LPCTSTR |
src = NULL, |
|
|
char |
ch = '\"', |
|
|
char |
esc = '\\' |
|
) |
[static] |
|
|
|
Unquotes a string, converting escape sequences as needed.
- Parameters:
-
| [out] | dst | - Receives unquoted string |
| [in] | src | - Quoted string |
| [in] | ch | - Quote character |
| [in] | esc | - Escape character |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::ValidateCRC32 |
( |
LPCTSTR |
pFile, |
|
|
LPDWORD |
pCrc = NULL |
|
) |
[static] |
|
|
|
Validates the crc of the given file.
- Parameters:
-
| [in] | pFile | - Filename to validate |
| [in] | pCrc | |
This function calculates the CRC for the file, then compares it with the last four bytes in the file which are assumed to be the CRC. You can add the CRC to the file by calling AddCRC32().
- Returns:
- Non-zero if CRC is valid
- See also:
|
| BOOL CWinFile::ValidateModuleCRC32 |
( |
HMODULE |
hModule = NULL, |
|
|
LPDWORD |
pCrc = NULL |
|
) |
[static] |
|
|
|
Validates the CRC of the specified module.
- Parameters:
-
| [in] | hModule | - Handle to module to validate |
| [in] | pCrc | - Receives the CRC. Can be NULL |
This function calculates the CRC for the module file, then compares it with the last four bytes in the file which are assumed to be the CRC. You can add the CRC to the file by calling AddCRC32().
- Warning:
- This is a somewhat outdated way of validating an executable file. New programs should use Digital Signatures.
- Returns:
- Non-zero if CRC is valid
- See also:
|
| BOOL CWinFile::VerboseCleanup |
( |
HWND |
hWnd = NULL, |
|
|
DWORD |
dwAttempts = 5 |
|
) |
[static] |
|
|
|
Attempts to delete temporary directories and files.
- Parameters:
-
| [in] | hWnd | - Handle to parent window. Can be NULL. |
| [in] | dwAttempts | - Number of attempts to delete |
This function attempts to delete named temporary files and folders. If there is a failure, the function prompts the user for desired action with a standard windows retry/cancel/ignore dialog box.
- Returns:
- Non-zero if all directories and files are deleted.
- See also:
|
| LPCTSTR CWinFile::WebBuildPath |
( |
LPSTR |
pFullPath, |
|
|
LPCTSTR |
pPath, |
|
|
LPCTSTR |
pFileName |
|
) |
[static] |
|
|
|
Builds a path using the forward slash '/'.
- Parameters:
-
| [in] | pFullPath | - Receives the final filename |
| [in] | pPath | - Path |
| [in] | pFileName | - Filename |
The same buffer can be used for multiple parameters.
- Returns:
- Pointer in pFullPath
- See also:
|
| BOOL CWinFile::Write |
( |
LPVOID |
pBuf, |
|
|
DWORD |
dwLen = 0, |
|
|
LPDWORD |
pdwWritten = NULL, |
|
|
BOOL |
bBypassCache = FALSE |
|
) |
[virtual] |
|
|
|
Writes data into file.
- Parameters:
-
| [in] | pBuf | - Pointer to data to write |
| [in] | dwLen | - Number of bytes in pBuf to write |
| [out] | pdwWritten | - Number of bytes written to file |
| [in] | bBypassCache | - Non-zero to bypass disk cache |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CWinFile::WriteCache |
( |
LPVOID |
pBuffer, |
|
|
DWORD |
dwLength, |
|
|
LPDWORD |
pdwWritten |
|
) |
|
|
|
|
Writes data to cache.
- Parameters:
-
| [in] | pBuffer | - Pointer to data |
| [in] | dwLength | - Number of bytes in pBuffer |
| [out] | pdwWritten | - Number of bytes written |
- Returns:
- Non-zero if success
- See also:
|
The documentation for this class was generated from the following files:
|