rcutils  master
C API providing common utilities and data structures.
filesystem.h
Go to the documentation of this file.
1 // Copyright 2017 Open Source Robotics Foundation, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef RCUTILS__FILESYSTEM_H_
16 #define RCUTILS__FILESYSTEM_H_
17 
18 #ifdef __cplusplus
19 extern "C"
20 {
21 #endif
22 
23 #include <stdbool.h>
24 #include <stddef.h>
25 
26 #include "rcutils/allocator.h"
27 #include "rcutils/macros.h"
29 
31 
40 bool
41 rcutils_get_cwd(char * buffer, size_t max_length);
42 
44 
51 bool
52 rcutils_is_directory(const char * abs_path);
53 
55 
62 bool
63 rcutils_is_file(const char * abs_path);
64 
66 
73 bool
74 rcutils_exists(const char * abs_path);
75 
77 
84 bool
85 rcutils_is_readable(const char * abs_path);
86 
88 
95 bool
96 rcutils_is_writable(const char * abs_path);
97 
99 
106 bool
107 rcutils_is_readable_and_writable(const char * abs_path);
108 
110 
123 char *
125  const char * left_hand_path,
126  const char * right_hand_path,
127  rcutils_allocator_t allocator);
128 
130 
142 char *
144  const char * path,
145  rcutils_allocator_t allocator);
146 
148 
166 bool
167 rcutils_mkdir(const char * abs_path);
168 
170 /*
171  * Calculates the size of a directory by summarizing the file size of all files.
172  * \note This operation is not recursive.
173  * \param[in] directory_path The directory path to calculate the size of.
174  * \param[in] allocator Allocator being used for internal file path composition.
175  * \return The size of the directory in bytes.
176  */
178 size_t
179 rcutils_calculate_directory_size(const char * directory_path, rcutils_allocator_t allocator);
180 
182 /*
183  * \param[in] file_path The path of the file to obtain its size of.
184  * \return The size of the file in bytes.
185  */
187 size_t
188 rcutils_get_file_size(const char * file_path);
189 
190 #ifdef __cplusplus
191 }
192 #endif
193 
194 #endif // RCUTILS__FILESYSTEM_H_
rcutils_is_file
bool rcutils_is_file(const char *abs_path)
Check if the provided path points to a file.
macros.h
rcutils_mkdir
bool rcutils_mkdir(const char *abs_path)
Create the specified directory.
rcutils_is_readable
bool rcutils_is_readable(const char *abs_path)
Check if the provided path points to a file/folder readable by current user.
rcutils_is_directory
bool rcutils_is_directory(const char *abs_path)
Check if the provided path points to a directory.
rcutils_get_file_size
size_t rcutils_get_file_size(const char *file_path)
Calculate the size of the specifed file.
rcutils_get_cwd
bool rcutils_get_cwd(char *buffer, size_t max_length)
Return current working directory.
RCUTILS_WARN_UNUSED
#define RCUTILS_WARN_UNUSED
Definition: macros.h:24
rcutils_is_writable
bool rcutils_is_writable(const char *abs_path)
Check if the provided path points to a file/folder writable by current user.
visibility_control.h
rcutils_exists
bool rcutils_exists(const char *abs_path)
Check if the provided path points to an existing file/folder.
rcutils_to_native_path
char * rcutils_to_native_path(const char *path, rcutils_allocator_t allocator)
Return newly allocated string with all argument's "/" replaced by platform specific separator.
rcutils_allocator_t
Encapsulation of an allocator.
Definition: allocator.h:45
allocator.h
RCUTILS_PUBLIC
#define RCUTILS_PUBLIC
Definition: visibility_control.h:23
rcutils_join_path
char * rcutils_join_path(const char *left_hand_path, const char *right_hand_path, rcutils_allocator_t allocator)
Return newly allocated string with arguments separated by correct delimiter for the platform.
rcutils_calculate_directory_size
size_t rcutils_calculate_directory_size(const char *directory_path, rcutils_allocator_t allocator)
Calculate the size of the specified directory.
rcutils_is_readable_and_writable
bool rcutils_is_readable_and_writable(const char *abs_path)
Check if the provided path points to a file/folder both readable and writable by current user.