Function rcutils_calculate_directory_size_with_recursion
Defined in File filesystem.h
Function Documentation
-
rcutils_ret_t rcutils_calculate_directory_size_with_recursion(const char *directory_path, const size_t max_depth, uint64_t *size, rcutils_allocator_t allocator)
Calculate the size of the specified directory with recursion.
Calculates the size of a directory and subdirectory by summarizing the file size of all files. If necessary, you can specify the maximum directory depth to recurse into. Depth definition as below.
directory_path <= depth 1 |- subdirectory <= depth 2 |- subdirectory <= depth 3 ...
Note
This API does not follow symlinks to files or directories.
- Parameters:
directory_path – [in] The directory path to calculate the size of.
max_depth – [in] The maximum depth of subdirectory. 0 means no limitation.
size – [out] The size of the directory in bytes on success.
allocator – [in] Allocator being used for internal file path composition.
- Returns:
RCUTILS_RET_OK if successful, or
- Returns:
RCUTILS_RET_INVALID_ARGUMENT for invalid arguments, or
- Returns:
RCUTILS_RET_BAD_ALLOC if memory allocation fails
- Returns:
RCUTILS_RET_ERROR if other error occurs