Last change
on this file since 2 was 2, checked in by root, 23 years ago |
Initial revision
|
-
Property svn:eol-style
set to
native
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.3 KB
|
Line | |
---|
1 | #define INCL_DOS
|
---|
2 |
|
---|
3 | #include <os2.h>
|
---|
4 | #include <stdlib.h>
|
---|
5 | #include <stdio.h>
|
---|
6 | #include <string.h>
|
---|
7 |
|
---|
8 | #pragma data_seg(DATA1)
|
---|
9 | #pragma alloc_text(MISC9,first_path,searchapath,searchpath)
|
---|
10 |
|
---|
11 | CHAR * first_path (CHAR *path,CHAR *ret) {
|
---|
12 |
|
---|
13 | CHAR *p,*pp;
|
---|
14 |
|
---|
15 | if(!path || !ret)
|
---|
16 | return ret;
|
---|
17 | strcpy(ret,path);
|
---|
18 | p = strchr(ret,';');
|
---|
19 | if(p) {
|
---|
20 | *p = 0;
|
---|
21 | p++;
|
---|
22 | if(*ret == '.') { /* skip initial "cur dir" */
|
---|
23 | pp = strchr(p,';');
|
---|
24 | if(pp)
|
---|
25 | *pp = 0;
|
---|
26 | if(*p)
|
---|
27 | memmove(ret,p,strlen(p) + 1);
|
---|
28 | }
|
---|
29 | }
|
---|
30 | return ret;
|
---|
31 | }
|
---|
32 |
|
---|
33 |
|
---|
34 | CHAR * searchapath (CHAR *path,CHAR *filename) {
|
---|
35 |
|
---|
36 | static CHAR fbuf[CCHMAXPATH];
|
---|
37 |
|
---|
38 | if(strchr(filename,'\\') || strchr(filename,'/') || strchr(filename,':')) {
|
---|
39 |
|
---|
40 | FILESTATUS3 fsa;
|
---|
41 |
|
---|
42 | if(!DosQueryPathInfo(filename,FIL_STANDARD,&fsa,
|
---|
43 | (ULONG)sizeof(fsa)))
|
---|
44 | return filename;
|
---|
45 | *fbuf = 0;
|
---|
46 | return fbuf;
|
---|
47 | }
|
---|
48 | *fbuf = 0;
|
---|
49 | if(DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT |
|
---|
50 | SEARCH_CUR_DIRECTORY,
|
---|
51 | path,filename,fbuf,CCHMAXPATH - 1))
|
---|
52 | *fbuf = 0;
|
---|
53 | return fbuf;
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 | CHAR * searchpath (CHAR *filename) {
|
---|
58 |
|
---|
59 | CHAR *found;
|
---|
60 |
|
---|
61 | if(!filename)
|
---|
62 | return "";
|
---|
63 | found = searchapath("PATH",filename);
|
---|
64 | if(!*found) {
|
---|
65 | found = searchapath("DPATH",filename);
|
---|
66 | if(!*found)
|
---|
67 | found = searchapath("XPATH",filename);
|
---|
68 | }
|
---|
69 | return found;
|
---|
70 | }
|
---|
71 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.