Changeset 286
- Timestamp:
- Jun 19, 2005, 7:32:42 PM (20 years ago)
- Files:
-
- 4 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; -
trunk/include/helpers/dosh.h
r257 r286 742 742 743 743 APIRET doshSearchPath(PCSZ pcszPath, 744 PCSZ pcszFile, 745 PSZ pszExecutable, 746 ULONG cbExecutable); 747 748 // added V1.0.4 (2005-06-16) [chennecke] 749 APIRET doshSearchDirs(PCSZ pcszDirList, 744 750 PCSZ pcszFile, 745 751 PSZ pszExecutable, -
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.