如下给出示例,Windows平台和linux平台通用:
BOOL IsFileExist(char * pszFilePath)
{
if (NULL == pszFilePath)
{
return FALSE;
}
#ifdef OS_WIN
DWORD dwRet = GetFileAttributesA(pszFilePath);
if (INVALID_FILE_ATTRIBUTES == dwRet)
{
return FALSE;
}
else {
return TRUE;
}
#else
int nRes = access(pszFilePath, F_OK);
return (nRes == 0) ? TRUE : FALSE;
#endif
}