2.1.2.23 is_str_valid_file_path


Description

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

Syntax

BOOL is_str_valid_file_path( LPCSTR lpFileName, int * pnCode = NULL )

Parameters

lpFileName
[input] file name string to check
pnCode
[output] when provided, this gives more info on the file path,
1 if drive letter path
2 if unc path
<0 means syntax error detected

Return

true if lpFilename is a valid syntax for a file name; otherwise false

Examples

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);
}

Remark

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.

See Also

is_str_has_path

Header to Include

origin.h

Reference