Changeset 286 for trunk/src/helpers/dosh2.c
- Timestamp:
- Jun 19, 2005, 7:32:42 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/dosh2.c
r265 r286 480 480 arc = ERROR_NOT_ENOUGH_MEMORY; 481 481 } 482 483 return arc; 484 } 485 486 /* 487 *@@ doshSearchDirs: 488 * This looks along all directories which are 489 * specified in the passed directory list 490 * if pcszFile is found. 491 * 492 * As opposed to the stupid DosSearchPath, this 493 * ignores subdirectories in the path particles. 494 * For example, DosSearchPath would usually not 495 * find an INSTALL file because \OS2 contains 496 * an INSTALL directory, or NETSCAPE because 497 * \OS2\INSTALL contains a NETSCAPE directory. 498 * 499 * Returns: 500 * 501 * -- NO_ERROR: pszExecutable has received the 502 * full path of pcszFile. 503 * 504 * -- ERROR_FILE_NOT_FOUND: pcszFile was not found 505 * in the specified path (or is a directory). 506 * 507 * -- ERROR_BUFFER_OVERFLOW: pcszFile was found, but 508 * the pszExecutable buffer is too small to hold 509 * the full path. 510 * 511 *@@added V1.0.4 (2005-06-16) [chennecke]: blatantly stolen from doshSearchPath 512 */ 513 514 APIRET doshSearchDirs(const char *pcszDirList, // in: list of directories in PATH style 515 const char *pcszFile, // in: file to look for (e.g. "LVM.EXE") 516 PSZ pszExecutable, // out: full path (e.g. "F:\os2\lvm.exe") 517 ULONG cbExecutable) // in: sizeof (*pszExecutable) 518 { 519 APIRET arc = NO_ERROR; 520 521 // run thru the path components 522 PSZ pszPathCopy; 523 if (pszPathCopy = strdup(pcszDirList)) 524 { 525 PSZ pszToken = strtok(pszPathCopy, ";"); 526 while (pszToken) 527 { 528 CHAR szFileMask[2*CCHMAXPATH]; 529 FILESTATUS3 fs3; 530 531 sprintf(szFileMask, 532 "%s\\%s", 533 pszToken, // path particle 534 pcszFile); // e.g. "netscape" 535 536 if ( (!(arc = DosQueryPathInfo(szFileMask, 537 FIL_STANDARD, 538 &fs3, 539 sizeof(fs3)))) 540 // make sure it's not a directory 541 // and that it's not hidden 542 && (!(fs3.attrFile & (FILE_DIRECTORY | FILE_HIDDEN))) 543 ) 544 { 545 // copy 546 arc = CopyToBuffer(pszExecutable, 547 szFileMask, 548 cbExecutable); 549 // and stop 550 break; 551 } 552 else 553 arc = ERROR_FILE_NOT_FOUND; 554 // and search on 555 556 pszToken = strtok(NULL, ";"); 557 }; 558 559 free(pszPathCopy); 560 } 561 else 562 arc = ERROR_NOT_ENOUGH_MEMORY; 482 563 483 564 return arc;
Note:
See TracChangeset
for help on using the changeset viewer.