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