Changeset 1247 for trunk/dll/pathutil.c
- Timestamp:
- Oct 15, 2008, 3:44:29 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/pathutil.c
r1211 r1247 12 12 06 Jan 08 GKY Add NormalizeCmdLine to check program strings on entry 13 13 29 Feb 08 GKY Changes to enable user settable command line length 14 15 Oct 08 GKY Fix NormalizeCmdLine to check all 5 executible extensions when no extension provided; 15 use searchapath to check for existance of file types not checked by DosQAppType; 16 close DosFind. 14 17 15 18 ***********************************************************************/ … … 26 29 #include "init.h" // Data declaration(s) 27 30 #include "fm3str.h" 31 #include "srchpath.h" // searchapath 28 32 #include "pathutil.h" 29 33 #include "strips.h" // remove_first_occurence_of_character … … 126 130 ULONG ulAppType; 127 131 char *pszChar; 132 char *FullPath; 128 133 FILEFINDBUF3 FindBuffer; 129 134 ULONG ulResultBufLen = sizeof(FILEFINDBUF3); … … 181 186 GetPString(IDS_QUOTESINARGSTEXT), 182 187 pszCmdLine_); 183 if (!offsetexe ) {188 if (!offsetexe && !offsetcom) { 184 189 ret = DosFindFirst(szCmdLine, &hdirFindHandle, FILE_NORMAL, &FindBuffer, 185 190 ulResultBufLen, &ulFindCount, FIL_STANDARD); 186 if (ret) { 187 pszChar = szCmdLine; 188 while (pszChar) { 189 if (*pszChar == ' ') { 190 *pszChar = '\0'; 191 strcat(szCmdLine, ".exe"); 192 ret = DosQueryAppType(szCmdLine, &ulAppType); 193 //printf("%d %s\n", ret, szCmdLine); fflush(stdout); 194 if (!ret) { 195 strcpy(szArgs, pszCmdLine_ + strlen(szCmdLine) - 3); 196 break; 197 } 198 } 199 strcpy(szCmdLine, pszCmdLine_); 200 pszChar++; 201 } 202 } 191 if (ret) { 192 FullPath = searchapath("PATH", szCmdLine); 193 if (*FullPath != 0) 194 ret = 0; 195 } 196 DosFindClose(hdirFindHandle); 203 197 } 204 198 else … … 229 223 230 224 } 225 // if it doesn't have an extension try it with all the standard ones and add if found 231 226 else if (szCmdLine && (!strchr(szCmdLine, '.') || 232 strrchr(szCmdLine, '.' ) < strrchr(szCmdLine, '\\'))) {227 strrchr(szCmdLine, '.' ) < strrchr(szCmdLine, '\\'))) { 233 228 if (!strchr(szCmdLine, ' ')) { 229 // strip quotes readded by BuildQuotedFileName 234 230 while (strchr(szCmdLine, '\"')) 235 231 remove_first_occurence_of_character("\"", szCmdLine); 236 strcat(szCmdLine, ".exe"); 237 ret = DosFindFirst(szCmdLine, &hdirFindHandle, FILE_NORMAL, &FindBuffer, 238 ulResultBufLen, &ulFindCount, FIL_STANDARD); 232 ret = DosQueryAppType(szCmdLine, &ulAppType); 233 if (!ret) 234 strcat(szCmdLine, ".exe"); 235 else { 236 strcat(szCmdLine, ".com"); 237 ret = DosQueryAppType(szCmdLine, &ulAppType); 238 if (ret) { 239 offset = strrchr(szCmdLine, '.' ); 240 *offset = 0; 241 strcat(szCmdLine, ".cmd"); 242 FullPath = searchapath("PATH", szCmdLine); 243 if (*FullPath != 0) 244 ret = 0; 245 else { 246 offset = strrchr(szCmdLine, '.' ); 247 *offset = 0; 248 strcat(szCmdLine, ".bat"); 249 FullPath = searchapath("PATH", szCmdLine); 250 if (*FullPath != 0) 251 ret = 0; 252 else { 253 offset = strrchr(szCmdLine, '.' ); 254 *offset = 0; 255 strcat(szCmdLine, ".bmt"); 256 FullPath = searchapath("PATH", szCmdLine); 257 if (*FullPath != 0) 258 ret = 0; 259 } 260 } 261 } 262 } 239 263 //printf("%d", ret); fflush(stdout); 240 264 } … … 244 268 while (strchr(szCmdLine, '\"')) 245 269 remove_first_occurence_of_character("\"", szCmdLine); 246 if (*pszChar == ' ') { 270 if (*pszChar == ' ') { //test at every space for the end of the filename 247 271 *pszChar = '\0'; 248 strcat(szCmdLine, ".exe"); 249 ret = DosQueryAppType(szCmdLine, &ulAppType); 272 ret = DosQueryAppType(szCmdLine, &ulAppType); 273 if (!ret) { 274 strcat(szCmdLine, ".exe"); 275 break; 276 } 277 else { 278 strcat(szCmdLine, ".com"); 279 ret = DosQueryAppType(szCmdLine, &ulAppType); 280 if (ret) { 281 offset = strrchr(szCmdLine, '.' ); 282 *offset = 0; 283 strcat(szCmdLine, ".cmd"); 284 FullPath = searchapath("PATH", szCmdLine); 285 if (*FullPath != 0) { 286 ret = 0; 287 break; 288 } 289 else { 290 offset = strrchr(szCmdLine, '.' ); 291 *offset = 0; 292 strcat(szCmdLine, ".bat"); 293 FullPath = searchapath("PATH", szCmdLine); 294 if (*FullPath != 0) { 295 ret = 0; 296 break; 297 } 298 else { 299 offset = strrchr(szCmdLine, '.' ); 300 *offset = 0; 301 strcat(szCmdLine, ".bmt"); 302 FullPath = searchapath("PATH", szCmdLine); 303 if (*FullPath != 0) { 304 ret = 0; 305 break; 306 } 307 } 308 } 309 } 310 else 311 break; 312 } 250 313 //printf("%d %s\n", ret, szCmdLine); fflush(stdout); 251 if (!ret) {252 break;253 }254 314 } 255 315 strcpy(szCmdLine, pszCmdLine_); … … 273 333 strcat(pszNewCmdLine, szArgs); 274 334 } 275 else { 335 else { // fail if no extension can be found we require one 276 336 ret = saymsg(MB_OK, 277 337 HWND_DESKTOP, … … 283 343 } 284 344 } 285 else { 345 else { // file has a nonstandard extension for executible 286 346 pszChar = strrchr(szCmdLine, '.'); 287 347 while (pszChar && *pszChar !=' ') { … … 302 362 pszCmdLine_); 303 363 ret = DosFindFirst(szCmdLine, &hdirFindHandle, FILE_NORMAL, &FindBuffer, 304 305 364 ulResultBufLen, &ulFindCount, FIL_STANDARD); 365 DosFindClose(hdirFindHandle); 306 366 BldQuotedFileName(pszNewCmdLine, szCmdLine); 307 367 //printf("%d %s ", ret, szCmdLine); fflush(stdout);
Note:
See TracChangeset
for help on using the changeset viewer.