Mercurial > trustbridge
annotate common/portpath.h @ 176:70d627e9e801
New portability function to test if a file is an directory.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Tue, 25 Mar 2014 16:45:32 +0100 |
parents | f100861dad8f |
children | 17e1c8f37d72 |
rev | line source |
---|---|
146
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
1 #ifndef PORTPATH_H |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
2 #define PORTPATH_H |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
3 |
168
f100861dad8f
Added simple portable function to test if an file exists.
Sascha Wilde <wilde@intevation.de>
parents:
167
diff
changeset
|
4 #include <stdbool.h> |
f100861dad8f
Added simple portable function to test if an file exists.
Sascha Wilde <wilde@intevation.de>
parents:
167
diff
changeset
|
5 |
146
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
6 /** |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
7 * @file portpath.h |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
8 * @brief Platform independent functions for file and path handling. |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
9 * @details portpath contains functions to handle file and path names |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
10 * in a platform independent way. The code unsing this functions |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
11 * should be protable between GNU/Linux and Windows32 systems. |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
12 */ |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
13 |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
14 /** |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
15 * @brief portable version of dirname |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
16 * @details return the directory component of the given path. |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
17 * The argument path may be altered by the function. |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
18 * @param[inout] path the pathname |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
19 * @returns a pointer to the string containing the directory component |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
20 */ |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
21 char *port_dirname(char *path); |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
22 |
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 * @brief portable version of realpath |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
25 * @details return the expanded absolute pathname for the given path. |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
26 * The buffer for the resolved path is allocated by this function and |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
27 * should be freed by the caller. |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
28 * @param[in] path the original pathname |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
29 * @returns a pointer to the resolved path or NULL on error |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
30 */ |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
31 char *port_realpath(char *path); |
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
32 |
168
f100861dad8f
Added simple portable function to test if an file exists.
Sascha Wilde <wilde@intevation.de>
parents:
167
diff
changeset
|
33 /** |
f100861dad8f
Added simple portable function to test if an file exists.
Sascha Wilde <wilde@intevation.de>
parents:
167
diff
changeset
|
34 * @brief test if a file exists |
f100861dad8f
Added simple portable function to test if an file exists.
Sascha Wilde <wilde@intevation.de>
parents:
167
diff
changeset
|
35 * @details uses a platform specific stat call to test if the given |
f100861dad8f
Added simple portable function to test if an file exists.
Sascha Wilde <wilde@intevation.de>
parents:
167
diff
changeset
|
36 * file exists. |
f100861dad8f
Added simple portable function to test if an file exists.
Sascha Wilde <wilde@intevation.de>
parents:
167
diff
changeset
|
37 * @param[in] path the path to the file |
f100861dad8f
Added simple portable function to test if an file exists.
Sascha Wilde <wilde@intevation.de>
parents:
167
diff
changeset
|
38 * @returns true if the file exists and false otherwise |
f100861dad8f
Added simple portable function to test if an file exists.
Sascha Wilde <wilde@intevation.de>
parents:
167
diff
changeset
|
39 */ |
f100861dad8f
Added simple portable function to test if an file exists.
Sascha Wilde <wilde@intevation.de>
parents:
167
diff
changeset
|
40 bool port_fileexits(char *path); |
f100861dad8f
Added simple portable function to test if an file exists.
Sascha Wilde <wilde@intevation.de>
parents:
167
diff
changeset
|
41 |
176
70d627e9e801
New portability function to test if a file is an directory.
Sascha Wilde <wilde@intevation.de>
parents:
168
diff
changeset
|
42 /** |
70d627e9e801
New portability function to test if a file is an directory.
Sascha Wilde <wilde@intevation.de>
parents:
168
diff
changeset
|
43 * @brief test if a file is a directory |
70d627e9e801
New portability function to test if a file is an directory.
Sascha Wilde <wilde@intevation.de>
parents:
168
diff
changeset
|
44 * @details uses a platform specific stat call to test if the given |
70d627e9e801
New portability function to test if a file is an directory.
Sascha Wilde <wilde@intevation.de>
parents:
168
diff
changeset
|
45 * file is an directory. |
70d627e9e801
New portability function to test if a file is an directory.
Sascha Wilde <wilde@intevation.de>
parents:
168
diff
changeset
|
46 * @param[in] path the path to the file |
70d627e9e801
New portability function to test if a file is an directory.
Sascha Wilde <wilde@intevation.de>
parents:
168
diff
changeset
|
47 * @returns true if the file is an directory and false otherwise |
70d627e9e801
New portability function to test if a file is an directory.
Sascha Wilde <wilde@intevation.de>
parents:
168
diff
changeset
|
48 */ |
70d627e9e801
New portability function to test if a file is an directory.
Sascha Wilde <wilde@intevation.de>
parents:
168
diff
changeset
|
49 bool port_isdir(char *path); |
70d627e9e801
New portability function to test if a file is an directory.
Sascha Wilde <wilde@intevation.de>
parents:
168
diff
changeset
|
50 |
146
306e4db11761
Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
51 #endif |