2.1.10.47 okutil_make_file_path
Description
make filepath from path, name, etc
Syntax
bool okutil_make_file_path( string * pstrFilePath, int nPathType, LPCSTR lpcszSubFolder, LPCSTR lpcszFileName, LPCSTR lpcszExt = NULL, bool bCheckExist = true )
Parameters
- pstrFilePath
- [output] a pointer to a string that holds the file path.
- nPathType
- [input] one of the constants in the enum ORIGIN_PATH_TYPE
- lpcszSubFolder
- [input] an optional subfolder "FitFunc\\ABC", or NULL. Leave off final backslash. It will be added.
- lpcszFileName
- [input] file name with or without extension, if with extension, then lpcszExt must be NULL
- lpcszExt
- [input] file extension including the dot ".ext"
- bCheckExist
- [input] if specified path and file can be constructed, then set this to true will further test if file actually existed
Return
Returns true if full path is constructed and exists if bCheckExist is true. If bCheckExist is false, returns true is file path constructed.
Examples
EX1
void make_file_path_ex1()
{
string strFilePath;
bool bReturn, bCheckExist = false;
bReturn = okutil_make_file_path(strFilePath, ORIGIN_PATH_USER, "FitFunc", "simplefilename", ".fdf", bCheckExist);
printf("The path made from ORIGIN_PATH_USER, FitFunc, simplefilename, .fdf is \n%s\n\n", strFilePath);
// if the filemname has extension, then set lpcszExt to NULL
bReturn = okutil_make_file_path(strFilePath, ORIGIN_PATH_USER, "FitFunc", "filename.fdf", NULL, bCheckExist);
printf("The path made from ORIGIN_PATH_USER, FitFunc, filename.fdf is \n%s\n\n", strFilePath);
// the subfolder can be NULL
bReturn = okutil_make_file_path(strFilePath, ORIGIN_PATH_USER, NULL, "filename.fdf", NULL, bCheckExist);
printf("The path made from ORIGIN_PATH_USER, filename.fdf is \n%s\n\n", strFilePath);
// if bCheckExist is true, then
bCheckExist = true;
bReturn = okutil_make_file_path(strFilePath, ORIGIN_PATH_USER, "FitFunc", "filename.fdf", NULL, bCheckExist);
if(bReturn)
printf("The path \n%s\nexists on my computer.\n\n", strFilePath);
else
printf("The path \n%s\ndoes not exist on my computer.\n\n", strFilePath);
}
Remark
See Also
okutil_get_origin_path_type
Header to Include
origin.h
Reference
|