Mercurial > trustbridge
annotate common/portpath.c @ 167:92d7e0b40808
Removed spurious duplication.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Tue, 25 Mar 2014 12:54:47 +0100 |
parents | 199878f09bf1 |
children | f100861dad8f |
rev | line source |
---|---|
146
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
1 #include "portpath.h" |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
2 |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
3 #include <libgen.h> |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
4 #include <limits.h> |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
5 #include <stdio.h> |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
6 #include <stdlib.h> |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
7 |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
8 |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
9 char * |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
10 port_dirname(char *path) |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
11 { |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
12 #ifndef _WIN32 |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
13 return dirname(path); |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
14 #else |
164
6d64d7e9fa32
Implemented port_dirname for windows.
Sascha Wilde <wilde@intevation.de>
parents:
146
diff
changeset
|
15 char drive[_MAX_DRIVE]; |
6d64d7e9fa32
Implemented port_dirname for windows.
Sascha Wilde <wilde@intevation.de>
parents:
146
diff
changeset
|
16 char dir[_MAX_DIR]; |
6d64d7e9fa32
Implemented port_dirname for windows.
Sascha Wilde <wilde@intevation.de>
parents:
146
diff
changeset
|
17 _splitpath(path, drive, dir, NULL, NULL); |
6d64d7e9fa32
Implemented port_dirname for windows.
Sascha Wilde <wilde@intevation.de>
parents:
146
diff
changeset
|
18 /* We assume: drive + dir is shorter than |
6d64d7e9fa32
Implemented port_dirname for windows.
Sascha Wilde <wilde@intevation.de>
parents:
146
diff
changeset
|
19 * drive + dir + fname + ext */ |
6d64d7e9fa32
Implemented port_dirname for windows.
Sascha Wilde <wilde@intevation.de>
parents:
146
diff
changeset
|
20 sprintf(path, "%s%s", drive, dir); |
6d64d7e9fa32
Implemented port_dirname for windows.
Sascha Wilde <wilde@intevation.de>
parents:
146
diff
changeset
|
21 return path; |
146
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
22 #endif |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
23 } |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
24 |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
25 char * |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
26 port_realpath(char *path) |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
27 { |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
28 #ifndef _WIN32 |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
29 return realpath(path, NULL); |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
30 #else |
165
d47de01d6ad7
Implemented port_realpath for windows.
Sascha Wilde <wilde@intevation.de>
parents:
164
diff
changeset
|
31 return _fullpath(NULL, path, 0); |
146
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
32 #endif |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
33 } |