This call provides a general path search mechanism that allows applications to find files residing along paths. The path string may come from the process environment, or be supplied directly by the caller.
DosSearchPath
Control (USHORT) - input
Bit
0 = The PathRef points to the actual search path. The search path string may be anywhere in the calling process's address space. Therefore, it may be in the environment, but is not required.
1 = The PathRef points to the name of an environment variable in the process environment, and that environment variable contains the search path.
0 = DosSearchPath only searches the current directory if it appears in the search path.
1 = DosSearchPath searches the current working directory before it searches the directories in the search path.
For example, implied current bit = 0 and path = ".\;a;b" is equivalent to implied current bit = 1 and path = "a;b".
A search path consists of a sequence of paths separated by a semicolon (;). It is a single ASCIIZ string. The directories are searched in the order they appear in the path.
If the path source bit of control = 1, PathRef is the name of an environment variable, that contains the search path.
A search path consists of a sequence of paths separated by ";". It is a single ASCIIZ string. The directories are searched in the order they appear in the path. Paths that contain ";"s should be quoted. For example:
"c:&this is ; one directory path";thisisanother
Environment variable names are simply strings that match name strings in the environment. The equal (=) sign is not part of the name. FileName (PSZ) - input
PathRef always points to an ASCIIZ string. Let DPATH be an environment variable in the environment segment of the process.
"DPATH=c:\sysdir;c:\init" /* in the environment */
The following two code fragments are equivalent:
DosScanEnv("DPATH", &PathRef); DosSearchPath(0, /* Path Source Bit = 0 */ PathRef, "myprog.ini", &ResultBuffer, ResultBufLen); DosSearchPath(2, /* Path Source Bit = 1 */ "DPATH", "myprog.ini", &ResultBuffer, ResultBufLen);
They both use the search path stored as DPATH in the environment segment. In the first case, the application uses DosScanEnv to find the variable: in the second case DosSearchPath calls DosScanEnv for the application.
DosSearchPath does not check for consistency or formatting on the names. It does a DosFindFirst on a series of names it constructs from PathRef and FileName.
To determine the size of the returned path name, the ResultBuffer must be scanned for the ASCIIZ terminator.
DosQSysInfo must be used by an application to determine the maximum path length supported by OS/2. The returned value should be used to dynamically allocate buffers that are to be used to store paths.