Changeset 1248 for trunk/dll/pathutil.c
- Timestamp:
- Oct 16, 2008, 12:10:00 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/pathutil.c
r1247 r1248 116 116 /** NormalizeCmdLine 117 117 * Checks a command line for common errors (missing quotes, missing extension, 118 * no space between exe and args etc) 118 * no space between exe and args etc) Also check for the existance of the file 119 * and checks .com and .exe file headers. 119 120 * Command line passed as pszCmdLine_ 120 121 * A pointer to a buffer of the size MaxComLineStrg should be supplied in … … 131 132 char *pszChar; 132 133 char *FullPath; 133 FILEFINDBUF3 FindBuffer;134 ULONG ulResultBufLen = sizeof(FILEFINDBUF3);135 HDIR hdirFindHandle = HDIR_CREATE;136 ULONG ulFindCount = 1;137 134 PSZ pszNewCmdLine = pszWorkBuf; 138 135 … … 187 184 pszCmdLine_); 188 185 if (!offsetexe && !offsetcom) { 189 ret = DosFindFirst(szCmdLine, &hdirFindHandle, FILE_NORMAL, &FindBuffer, 190 ulResultBufLen, &ulFindCount, FIL_STANDARD); 191 if (ret) { 192 FullPath = searchapath("PATH", szCmdLine); 193 if (*FullPath != 0) 194 ret = 0; 195 } 196 DosFindClose(hdirFindHandle); 186 FullPath = searchapath("PATH", szCmdLine); 187 if (*FullPath) 188 ret = 0; 197 189 } 198 190 else … … 230 222 while (strchr(szCmdLine, '\"')) 231 223 remove_first_occurence_of_character("\"", szCmdLine); 232 ret = DosQueryAppType(szCmdLine, &ulAppType); 224 ret = DosQueryAppType(szCmdLine, &ulAppType); // exe automatically appended 233 225 if (!ret) 234 226 strcat(szCmdLine, ".exe"); … … 241 233 strcat(szCmdLine, ".cmd"); 242 234 FullPath = searchapath("PATH", szCmdLine); 243 if (*FullPath != 0)235 if (*FullPath) 244 236 ret = 0; 245 237 else { 246 offset = strrchr(szCmdLine, '.' );247 238 *offset = 0; 248 239 strcat(szCmdLine, ".bat"); 249 240 FullPath = searchapath("PATH", szCmdLine); 250 if (*FullPath != 0)241 if (*FullPath) 251 242 ret = 0; 252 243 else { 253 offset = strrchr(szCmdLine, '.' );254 244 *offset = 0; 255 245 strcat(szCmdLine, ".bmt"); 256 246 FullPath = searchapath("PATH", szCmdLine); 257 if (*FullPath != 0)247 if (*FullPath) 258 248 ret = 0; 259 249 } … … 283 273 strcat(szCmdLine, ".cmd"); 284 274 FullPath = searchapath("PATH", szCmdLine); 285 if (*FullPath != 0) {275 if (*FullPath) { 286 276 ret = 0; 287 277 break; 288 278 } 289 279 else { 290 offset = strrchr(szCmdLine, '.' );291 280 *offset = 0; 292 281 strcat(szCmdLine, ".bat"); 293 282 FullPath = searchapath("PATH", szCmdLine); 294 if (*FullPath != 0) {283 if (*FullPath) { 295 284 ret = 0; 296 285 break; 297 286 } 298 287 else { 299 offset = strrchr(szCmdLine, '.' );300 288 *offset = 0; 301 289 strcat(szCmdLine, ".bmt"); 302 290 FullPath = searchapath("PATH", szCmdLine); 303 if (*FullPath != 0) {291 if (*FullPath) { 304 292 ret = 0; 305 293 break; … … 333 321 strcat(pszNewCmdLine, szArgs); 334 322 } 335 else { // fail if no extension can be found we requireone323 else { // fail if no extension can be found runemf2 requires one 336 324 ret = saymsg(MB_OK, 337 325 HWND_DESKTOP, … … 361 349 GetPString(IDS_QUOTESINARGSTEXT), 362 350 pszCmdLine_); 363 ret = DosFindFirst(szCmdLine, &hdirFindHandle, FILE_NORMAL, &FindBuffer, 364 ulResultBufLen, &ulFindCount, FIL_STANDARD); 365 DosFindClose(hdirFindHandle); 351 FullPath = searchapath("PATH", szCmdLine); 366 352 BldQuotedFileName(pszNewCmdLine, szCmdLine); 367 353 //printf("%d %s ", ret, szCmdLine); fflush(stdout); 368 if ( ret) {354 if (!*FullPath) { 369 355 ret = saymsg(MB_YESNO, 370 356 HWND_DESKTOP, … … 382 368 } 383 369 } 384 ret = saymsg(MB_YESNOCANCEL, 370 else { 371 ret = saymsg(MB_YESNOCANCEL, 385 372 HWND_DESKTOP, 386 373 NullStr, 387 374 GetPString(IDS_PROGRAMNOTEXE3TEXT), 388 375 pszCmdLine_, pszNewCmdLine); 389 if (ret == MBID_YES){ 390 if (szArgs[0] != ' ') 391 strcat(pszNewCmdLine, " "); 392 strcat(pszNewCmdLine, szArgs); 393 } 394 if (ret == MBID_CANCEL){ 395 fCancelAction = TRUE; 396 pszNewCmdLine = pszCmdLine_; 376 if (ret == MBID_YES){ 377 if (szArgs[0] != ' ') 378 strcat(pszNewCmdLine, " "); 379 strcat(pszNewCmdLine, szArgs); 380 } 381 if (ret == MBID_CANCEL){ 382 fCancelAction = TRUE; 383 pszNewCmdLine = pszCmdLine_; 384 } 397 385 } 398 386 }
Note:
See TracChangeset
for help on using the changeset viewer.