Test a string to see if it is in correct form for a file name (full path), this function does not care whether the file existed or not
BOOL is_str_valid_file_path( LPCSTR lpFileName, int * pnCode = NULL )
true if lpFilename is a valid syntax for a file name; otherwise false
EX1
void is_str_valid_file_path_ex1() { int pathinfo = 0; string strPath = "C:\\Program Files"; //change to "\\\\server\\current\\Origin8.0" to see different result bool bRet = is_str_valid_file_path(strPath , &pathinfo); if(bRet) { if(1==pathinfo) printf(" \"%s\" is a drive letter path" , strPath); else if(2==pathinfo) printf(" \"%s\" is a unc file path" , strPath); } else printf("\"%s\" is not a valid file path ",strPath); }
For the test string, some special characters were reserved by C/C++ standard, such as '\' and ' " '.If you want to use these characters in a C style string or a char type, you must prefix them with a backslash(\) escape character.
is_str_has_path
origin.h