rcutils  master
C API providing common utilities and data structures.
Functions
filesystem.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include "rcutils/allocator.h"
#include "rcutils/macros.h"
#include "rcutils/visibility_control.h"
Include dependency graph for filesystem.h:

Go to the source code of this file.

Functions

bool rcutils_get_cwd (char *buffer, size_t max_length)
 Return current working directory. More...
 
bool rcutils_is_directory (const char *abs_path)
 Check if the provided path points to a directory. More...
 
bool rcutils_is_file (const char *abs_path)
 Check if the provided path points to a file. More...
 
bool rcutils_exists (const char *abs_path)
 Check if the provided path points to an existing file/folder. More...
 
bool rcutils_is_readable (const char *abs_path)
 Check if the provided path points to a file/folder readable by current user. More...
 
bool rcutils_is_writable (const char *abs_path)
 Check if the provided path points to a file/folder writable by current user. More...
 
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. More...
 
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. More...
 
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. More...
 

Function Documentation

◆ rcutils_get_cwd()

bool rcutils_get_cwd ( char *  buffer,
size_t  max_length 
)

Return current working directory.

Parameters
[in]bufferAllocated string to store current directory path to
[in]max_lengthmaximum length to be stored in buffer
Returns
bool True if success False if buffer is NULL False on failure

◆ rcutils_is_directory()

bool rcutils_is_directory ( const char *  abs_path)

Check if the provided path points to a directory.

Parameters
[in]abs_pathAbsolute path to check.
Returns
bool True if directory False if abs_path is NULL False on failure

◆ rcutils_is_file()

bool rcutils_is_file ( const char *  abs_path)

Check if the provided path points to a file.

Parameters
[in]abs_pathAbsolute path to check.
Returns
bool True if file False if abs_path is NULL False on failure

◆ rcutils_exists()

bool rcutils_exists ( const char *  abs_path)

Check if the provided path points to an existing file/folder.

Parameters
[in]abs_pathAbsolute path to check.
Returns
bool True if the path exists False if abs_path is NULL False on failure

◆ 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.

Parameters
[in]abs_pathAbsolute path to check.
Returns
bool True if the file is readable False if abs_path is NULL False on failure

◆ 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.

Parameters
[in]abs_pathAbsolute path to check.
Returns
bool True if the file is writable False if abs_path is NULL False on failure

◆ 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.

Parameters
[in]abs_pathAbsolute path to check.
Returns
bool True if the file is redable and writable False otherwise False if abs_path is NULL False on failure

◆ 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.

This function allocates memory and returns it to the caller. It is up to the caller to release the memory once it is done with it by calling deallocate on the same allocator passed here.

Parameters
[in]left_hand_path
[in]right_hand_path
[in]allocator
Returns
char * concatenated path on success NULL on invalid arguments NULL on failure

◆ 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.

This function allocates memory and returns it to the caller. It is up to the caller to release the memory once it is done with it by calling deallocate on the same allocator passed here.

Parameters
[in]path
[in]allocator
Returns
char * path using platform specific delimiters on success NULL on invalid arguments NULL on failure