Rev 7184 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7184 | Rev 7520 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include |
1 | #include |
2 | #include |
2 | #include |
3 | #include |
3 | #include |
Line -... | Line 4... | ||
- | 4 | ||
- | 5 | int errno = 0; |
|
- | 6 | ||
- | 7 | /* |
|
- | 8 | // removed by Seiemargl 26-oct-2018 |
|
- | 9 | // use get_current_folder() from kos32sys.h instead |
|
- | 10 | ||
4 | 11 | ||
5 | extern char __argv; |
12 | extern char __argv; |
Line 6... | Line 13... | ||
6 | extern char __path; |
13 | extern char __path; |
7 | - | ||
8 | int errno = 0; |
14 | |
Line -... | Line 15... | ||
- | 15 | // convert relative to program path ./file.txt to absolute |
|
9 | 16 | const char* getfullpath(const char *path){ |
|
10 | const char* getfullpath(const char *path){ |
17 | |
11 | 18 | ||
12 | int relpath_pos, localpath_size; |
19 | int relpath_pos, localpath_size; |
Line 13... | Line 20... | ||
13 | char *programpath; |
20 | char *programpath; |
14 | char *newpath; |
21 | char *newpath; |
15 | char *prgname; |
22 | char *prgname; |
16 | 23 | ||
Line 17... | Line 24... | ||
17 | if (path[0] == '/') /* root */ |
24 | if (path[0] == '/') // |
18 | { |
25 | { |
19 | return(strdup(path)); /* dup need as free in fclose() */ |
26 | return(strdup(path)); // dup need as free in fclose() |
Line 47... | Line 54... | ||
47 | //copy filename to the new path |
54 | //copy filename to the new path |
48 | strcpy(newpath + localpath_size, path + relpath_pos); |
55 | strcpy(newpath + localpath_size, path + relpath_pos); |
Line 49... | Line 56... | ||
49 | 56 | ||
50 | return(newpath); |
57 | return(newpath); |
51 | } |
58 | } |
Line 52... | Line 59... | ||
52 | 59 | */ |
|
53 | 60 | ||
54 | 61 | ||
Line 90... | Line 97... | ||
90 | mode++; |
97 | mode++; |
91 | } |
98 | } |
92 | if (*mode!=0) |
99 | if (*mode!=0) |
93 | return NULL; |
100 | return NULL; |
Line 94... | Line 101... | ||
94 | 101 | ||
- | 102 | // fullname = (char*)getfullpath(filename); |
|
95 | fullname = (char*)getfullpath(filename); |
103 | fullname = strdup(filename); |
96 | if ((imode & 3) == FILE_OPEN_READ && fullname) /* check existense */ |
104 | if ((imode & 3) == FILE_OPEN_READ && fullname) /* check existense */ |
97 | { |
105 | { |
98 | sz = _ksys_get_filesize(fullname); |
106 | sz = _ksys_get_filesize(fullname); |
99 | if (sz < 0) |
107 | if (sz < 0) |