le_dir.h

Go to the documentation of this file.
1 /**
2  * @page c_dir Directory API
3  *
4  * @ref le_dir.h "API Reference"
5  *
6  * @section c_dir_create Creating Directories
7  *
8  * To create a directory at a specific location, call @c le_dir_Make() passing in the path name of the
9  * directory to create. All directories in the path name except the last directory (the directory
10  * to be created) must exist prior to calling le_dir_Make().
11  *
12  * To create all directories in a specified path use @c le_dir_MakePath().
13  *
14  * With both le_dir_Make() and le_dir_MakePath() the calling process must have write and search
15  * permissions on all directories in the path.
16  *
17  * @section c_dir_delete Removing Directories
18  *
19  * To remove a directory and everything in the directory (including all files and sub-directories)
20  * use @c le_dir_RemoveRecursive().
21  *
22  * @section c_dir_read Reading Directories
23  *
24  * To read the contents of a directory use the POSIX function @c openDir().
25  *
26  * <HR>
27  *
28  * Copyright (C) Sierra Wireless Inc.
29  */
30 
31 //--------------------------------------------------------------------------------------------------
32 /** @file le_dir.h
33  *
34  * Legato @ref c_dir include file.
35  *
36  * Copyright (C) Sierra Wireless Inc.
37  */
38 
39 #ifndef LEGATO_DIR_INCLUDE_GUARD
40 #define LEGATO_DIR_INCLUDE_GUARD
41 
42 
43 //--------------------------------------------------------------------------------------------------
44 /**
45  * Creates a directory with permissions specified in mode.
46  *
47  * @note Permissions for the created directory will depend on the calling process' umask.
48  *
49  * @return
50  * LE_OK if successful.
51  * LE_DUPLICATE if the directory already exists.
52  * LE_FAULT if there was an error.
53  */
54 //--------------------------------------------------------------------------------------------------
56 (
57  const char* pathNamePtr, ///< [IN] Path name to the directory to create.
58  mode_t mode ///< [IN] Permissions for the directory.
59 );
60 
61 
62 //--------------------------------------------------------------------------------------------------
63 /**
64  * Creates all directories in the path. If some (or all) directories in the path already exist,
65  * those directories are left as is. All created directories have the same permissions
66  * (specified in mode).
67  *
68  * @note Permissions for the created directories will depend on the calling process'
69  * umask.
70  *
71  * @return
72  * LE_OK if successful.
73  * LE_FAULT if there was an error.
74  */
75 //--------------------------------------------------------------------------------------------------
77 (
78  const char* pathNamePtr, ///< [IN] Path containing all the directories to create.
79  mode_t mode ///< [IN] Permissions for all created directories.
80 );
81 
82 
83 //--------------------------------------------------------------------------------------------------
84 /**
85  * Removes a directory by first recursively removing sub-directories, files, symlinks, hardlinks,
86  * devices, etc. Symlinks are not followed; only the links themselves are deleted.
87  *
88  * A file or device may not be able to be removed if it is busy, in which case an error message
89  * is logged and LE_FAULT is returned.
90  *
91  * @return
92  * LE_OK if successful.
93  * LE_FAULT if there was an error.
94  */
95 //--------------------------------------------------------------------------------------------------
97 (
98  const char* pathNamePtr ///< [IN] Path to the directory to remove.
99 );
100 
101 
102 //--------------------------------------------------------------------------------------------------
103 /**
104  * Checks if the path refers to a directory.
105  *
106  * @return
107  * true if the path refers to a directory. false otherwise.
108  */
109 //--------------------------------------------------------------------------------------------------
110 bool le_dir_IsDir
111 (
112  const char* pathNamePtr ///< [IN] The path to the directory.
113 );
114 
115 
116 #endif // LEGATO_DIR_INCLUDE_GUARD
le_result_t
Definition: le_basics.h:35
le_result_t le_dir_RemoveRecursive(const char *pathNamePtr)
le_result_t le_dir_MakePath(const char *pathNamePtr, mode_t mode)
bool le_dir_IsDir(const char *pathNamePtr)
le_result_t le_dir_Make(const char *pathNamePtr, mode_t mode)