Parsing Paths
-
Suppose i have a string like
CString csPath = "c:\\windows\\test.exe -parm1"
or
CString csPath = "c:\\windows\\test.exe /parm1"now to test whether
test.exe
exists or not i can't just use csPath and callGetFileAttributes
that will fail because of the commandline arguments i will have to extract the application path from the full command line which will be tedious(the examples above are easy but there are more complex ones like:C:\WINDOWS\ISUNINST.EXE -f"C:\Program Files\Adobe\Photoshop 5.5\Uninst.isu" -c"C:\Program Files\Adobe\Photoshop 5.5\Uninst.dll"
) any help suggestions are welcome
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
http://www.mastishk.com -
Suppose i have a string like
CString csPath = "c:\\windows\\test.exe -parm1"
or
CString csPath = "c:\\windows\\test.exe /parm1"now to test whether
test.exe
exists or not i can't just use csPath and callGetFileAttributes
that will fail because of the commandline arguments i will have to extract the application path from the full command line which will be tedious(the examples above are easy but there are more complex ones like:C:\WINDOWS\ISUNINST.EXE -f"C:\Program Files\Adobe\Photoshop 5.5\Uninst.isu" -c"C:\Program Files\Adobe\Photoshop 5.5\Uninst.dll"
) any help suggestions are welcome
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
http://www.mastishk.comPathRemoveArgs()
should help :)Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
Suppose i have a string like
CString csPath = "c:\\windows\\test.exe -parm1"
or
CString csPath = "c:\\windows\\test.exe /parm1"now to test whether
test.exe
exists or not i can't just use csPath and callGetFileAttributes
that will fail because of the commandline arguments i will have to extract the application path from the full command line which will be tedious(the examples above are easy but there are more complex ones like:C:\WINDOWS\ISUNINST.EXE -f"C:\Program Files\Adobe\Photoshop 5.5\Uninst.isu" -c"C:\Program Files\Adobe\Photoshop 5.5\Uninst.dll"
) any help suggestions are welcome
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
http://www.mastishk.comWhy not use: TCHAR szDrive[_MAX_DRIVE]; TCHAR szDir[_MAX_DIR]; TCHAR szFname[_MAX_FNAME]; TCHAR szExt[_MAX_EXT]; ::_tsplitpath(csPath, szDrive, szDir, szFname, szExt); Then, just check to see if you have the filename and extension in szFname and szExt.