doc
c_dir.h
Go to the documentation of this file.
1 /*
2  * cynapses libc functions
3  *
4  * Copyright (c) 2008 by Andreas Schneider <mail@cynapses.org>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * vim: ft=c.doxygen ts=2 sw=2 et cindent
21  */
22 
23 /**
24  * @file c_dir.h
25  *
26  * @brief Interface of the cynapses libc directory function
27  *
28  * @defgroup cynDirInternals cynapses libc directory functions
29  * @ingroup cynLibraryAPI
30  *
31  * @{
32  */
33 
34 #ifndef _C_DIR_H
35 #define _C_DIR_H
36 
37 #include <sys/types.h>
38 
39 
40 /**
41  * @brief Create parent directories as needed.
42  *
43  * The newly created directory will be owned by the effective user ID of the
44  * process.
45  *
46  * @param path The path to the directory to create.
47  *
48  * @param mode Specifies the permissions to use. It is modified
49  * by the process's umask in the usual way: the
50  * permissions of the created file are (mode & ~umask).
51  *
52  * @return 0 on success, < 0 on error with errno set:
53  * - EACCES The parent directory does not allow write
54  * permission to the process, or one of the directories
55  * - ENOTDIR if durl is not a directory
56  * - EINVAL NULL durl passed or smbc_init not called.
57  * - ENOMEM Insufficient memory was available.
58  *
59  * @see mkdir()
60  */
61 int c_mkdirs(const char *path, mode_t mode);
62 
63 /**
64  * @brief Remove the directory and subdirectories including the content.
65  *
66  * This removes all directories and files recursivly.
67  *
68  * @param dir The directory to remove recusively.
69  *
70  * @return 0 on success, < 0 on error with errno set.
71  */
72 int c_rmdirs(const char *dir);
73 
74 /**
75  * @brief Check if a path is a directory.
76  *
77  * @param path The path to check.
78  *
79  * @return 1 if the path is a directory, 0 if the path doesn't exist, is a
80  * file or can't be accessed.
81  */
82 int c_isdir(const char *path);
83 
84 /**
85  * }@
86  */
87 #endif /* _CDIR_H */
88 
mode_t mode
Definition: csync_private.h:70
int c_isdir(const char *path)
Check if a path is a directory.
char path[1]
Definition: csync_private.h:81
int c_rmdirs(const char *dir)
Remove the directory and subdirectories including the content.
int c_mkdirs(const char *path, mode_t mode)
Create parent directories as needed.