annotate common/portpath.h @ 1070:f110a3f6e387

(issue114) Fine tune ACL propagation using mkdir_p the ACL of the parent directories would propagate to all subdirectories and objects in the directory. Now we only use ACL propagation in the last directory to make sure that files we might create in that directory inherit the correct (resitricted) ACL
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 10 Sep 2014 16:41:36 +0200
parents faf58e9f518b
children fd7d04bb37cb
rev   line source
404
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 176
diff changeset
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 176
diff changeset
2 * Software engineering by Intevation GmbH
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 176
diff changeset
3 *
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 176
diff changeset
4 * This file is Free Software under the GNU GPL (v>=2)
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 176
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY!
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 176
diff changeset
6 * See LICENSE.txt for details.
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 176
diff changeset
7 */
146
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
8 #ifndef PORTPATH_H
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
9 #define PORTPATH_H
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
10
168
f100861dad8f Added simple portable function to test if an file exists.
Sascha Wilde <wilde@intevation.de>
parents: 167
diff changeset
11 #include <stdbool.h>
f100861dad8f Added simple portable function to test if an file exists.
Sascha Wilde <wilde@intevation.de>
parents: 167
diff changeset
12
146
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 * @file portpath.h
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
15 * @brief Platform independent functions for file and path handling.
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
16 * @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
17 * 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
18 * should be protable between GNU/Linux and Windows32 systems.
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
19 */
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 /**
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
22 * @brief portable version of dirname
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
23 * @details return the directory component of the given path.
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
24 * The argument path may be altered by the function.
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
25 * @param[inout] path the pathname
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
26 * @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
27 */
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
28 char *port_dirname(char *path);
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
29
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 * @brief portable version of realpath
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
32 * @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
33 * 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
34 * should be freed by the caller.
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
35 * @param[in] path the original pathname
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
36 * @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
37 */
975
b3695a3399de (issue86) Install into default directories on Linux
Andre Heinecke <andre.heinecke@intevation.de>
parents: 404
diff changeset
38 char *port_realpath(const char *path);
146
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
39
168
f100861dad8f Added simple portable function to test if an file exists.
Sascha Wilde <wilde@intevation.de>
parents: 167
diff changeset
40 /**
f100861dad8f Added simple portable function to test if an file exists.
Sascha Wilde <wilde@intevation.de>
parents: 167
diff changeset
41 * @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
42 * @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
43 * file exists.
f100861dad8f Added simple portable function to test if an file exists.
Sascha Wilde <wilde@intevation.de>
parents: 167
diff changeset
44 * @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
45 * @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
46 */
f100861dad8f Added simple portable function to test if an file exists.
Sascha Wilde <wilde@intevation.de>
parents: 167
diff changeset
47 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
48
176
70d627e9e801 New portability function to test if a file is an directory.
Sascha Wilde <wilde@intevation.de>
parents: 168
diff changeset
49 /**
70d627e9e801 New portability function to test if a file is an directory.
Sascha Wilde <wilde@intevation.de>
parents: 168
diff changeset
50 * @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
51 * @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
52 * 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
53 * @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
54 * @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
55 */
984
faf58e9f518b Add recursive mkdir and mkdir for windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 975
diff changeset
56 bool port_isdir(const char *path);
176
70d627e9e801 New portability function to test if a file is an directory.
Sascha Wilde <wilde@intevation.de>
parents: 168
diff changeset
57
975
b3695a3399de (issue86) Install into default directories on Linux
Andre Heinecke <andre.heinecke@intevation.de>
parents: 404
diff changeset
58 /**
b3695a3399de (issue86) Install into default directories on Linux
Andre Heinecke <andre.heinecke@intevation.de>
parents: 404
diff changeset
59 * @brief create a directory
b3695a3399de (issue86) Install into default directories on Linux
Andre Heinecke <andre.heinecke@intevation.de>
parents: 404
diff changeset
60 * @details uses a platform specific mkdir / access rights setup
b3695a3399de (issue86) Install into default directories on Linux
Andre Heinecke <andre.heinecke@intevation.de>
parents: 404
diff changeset
61 * to create a directory that is world readable and
b3695a3399de (issue86) Install into default directories on Linux
Andre Heinecke <andre.heinecke@intevation.de>
parents: 404
diff changeset
62 * writable by the current user / group
b3695a3399de (issue86) Install into default directories on Linux
Andre Heinecke <andre.heinecke@intevation.de>
parents: 404
diff changeset
63 * @param[in] path the path to the directory
1070
f110a3f6e387 (issue114) Fine tune ACL propagation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 984
diff changeset
64 * @param[in] propagate_acl weather or not objects should inherit
f110a3f6e387 (issue114) Fine tune ACL propagation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 984
diff changeset
65 * the ACL of this directory. Only has an effect on Windows.
975
b3695a3399de (issue86) Install into default directories on Linux
Andre Heinecke <andre.heinecke@intevation.de>
parents: 404
diff changeset
66 * @returns true if the directory was created
b3695a3399de (issue86) Install into default directories on Linux
Andre Heinecke <andre.heinecke@intevation.de>
parents: 404
diff changeset
67 */
1070
f110a3f6e387 (issue114) Fine tune ACL propagation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 984
diff changeset
68 bool port_mkdir(const char *path, bool propagate_acl);
975
b3695a3399de (issue86) Install into default directories on Linux
Andre Heinecke <andre.heinecke@intevation.de>
parents: 404
diff changeset
69
984
faf58e9f518b Add recursive mkdir and mkdir for windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 975
diff changeset
70 /**
faf58e9f518b Add recursive mkdir and mkdir for windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 975
diff changeset
71 * @brief create a directory and its parent directores
1070
f110a3f6e387 (issue114) Fine tune ACL propagation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 984
diff changeset
72 *
f110a3f6e387 (issue114) Fine tune ACL propagation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 984
diff changeset
73 * On Windows the last directory will propagate it's ACL
f110a3f6e387 (issue114) Fine tune ACL propagation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 984
diff changeset
74 * to objects and subdirectories. The parent directories
f110a3f6e387 (issue114) Fine tune ACL propagation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 984
diff changeset
75 * will not.
f110a3f6e387 (issue114) Fine tune ACL propagation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 984
diff changeset
76 *
f110a3f6e387 (issue114) Fine tune ACL propagation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 984
diff changeset
77 * @param[in] propagate_acl weather or not the
f110a3f6e387 (issue114) Fine tune ACL propagation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 984
diff changeset
78 * last created directory should propagate it's acl.
f110a3f6e387 (issue114) Fine tune ACL propagation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 984
diff changeset
79 * Only has an effect on Windows.
984
faf58e9f518b Add recursive mkdir and mkdir for windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 975
diff changeset
80 * @param[in] path the path to the directory
faf58e9f518b Add recursive mkdir and mkdir for windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 975
diff changeset
81 * @returns true if the directory was created
faf58e9f518b Add recursive mkdir and mkdir for windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 975
diff changeset
82 */
1070
f110a3f6e387 (issue114) Fine tune ACL propagation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 984
diff changeset
83 bool port_mkdir_p(const char *path, bool propagate_acl);
984
faf58e9f518b Add recursive mkdir and mkdir for windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 975
diff changeset
84
146
306e4db11761 Added portable path name handling functions.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
85 #endif

http://wald.intevation.org/projects/trustbridge/