Header File
stdlib.h
Category
Miscellaneous Routines
Prototype
void _searchstr(const char *file, const char *ipath, char *buf);
void _wsearchstr(const wchar_t *file, const wchar_t *ipath,wchar_t *pathname);
Description
Searches a list of directories for a file.
_searchstr attempts to locate file, searching along the path specified by the string ipath.
_searchstr searches for the file in the current directory of the current drive first. If the file is not found there, each directory in ipath is searched in turn until the file is found, or the path is exhausted. The directories in ipath must be separated by semicolons.
When the file is located, the full path name is stored in the buffer pointed by by buf. This string can be used in a call to access the file (for example, with fopen or exec...). The buffer is assumed to be large enough to store any possible file name. The constant _MAX_PATH defined in stdlib.h, is the size of the largest file name. If the file cannot be successfully located, an empty string (consisting of only a null character) will be stored at buf.
Return Value
None.
Example
#include <stdio.h> #include <stdlib.h> char buf[_MAX_PATH]; int main(void) { /* look for ILINK32.EXE */ _searchstr("ILINK32.EXE", "PATH", buf); if (buf[0] == '\0') printf ("ILINK32.EXE not found\n"); else printf ("ILINK32.EXE found in %s\n", buf); return 0; }
Portability
|
POSIX |
Win32 |
ANSI C |
ANSI C++ |
_searchstr |
|
+ |
|
|
_wsearchstr |
|
NT only |
|
|
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|