Program Listing for File filesystem.h

Return to documentation for file (include/rcutils/filesystem.h)

   |- subdirectory <= depth 2
           |- subdirectory <= depth 3
                   ...
// Copyright 2017 Open Source Robotics Foundation, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


#ifndef RCUTILS__FILESYSTEM_H_
#define RCUTILS__FILESYSTEM_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

#include "rcutils/allocator.h"
#include "rcutils/macros.h"
#include "rcutils/visibility_control.h"


RCUTILS_PUBLIC
RCUTILS_WARN_UNUSED
bool
rcutils_get_cwd(char * buffer, size_t max_length);


RCUTILS_PUBLIC
bool
rcutils_is_directory(const char * abs_path);


RCUTILS_PUBLIC
bool
rcutils_is_file(const char * abs_path);


RCUTILS_PUBLIC
bool
rcutils_exists(const char * abs_path);


RCUTILS_PUBLIC
bool
rcutils_is_readable(const char * abs_path);


RCUTILS_PUBLIC
bool
rcutils_is_writable(const char * abs_path);


RCUTILS_PUBLIC
bool
rcutils_is_readable_and_writable(const char * abs_path);


RCUTILS_PUBLIC
char *
rcutils_join_path(
  const char * left_hand_path,
  const char * right_hand_path,
  rcutils_allocator_t allocator);


RCUTILS_PUBLIC
char *
rcutils_to_native_path(
  const char * path,
  rcutils_allocator_t allocator);


RCUTILS_PUBLIC
char *
rcutils_expand_user(const char * path, rcutils_allocator_t allocator);


RCUTILS_PUBLIC
bool
rcutils_mkdir(const char * abs_path);


RCUTILS_PUBLIC
rcutils_ret_t
rcutils_calculate_directory_size(
  const char * directory_path,
  uint64_t * size,
  rcutils_allocator_t allocator);


RCUTILS_PUBLIC
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);


RCUTILS_PUBLIC
size_t
rcutils_get_file_size(const char * file_path);

typedef struct rcutils_dir_iter_s
{
  const char * entry_name;
  rcutils_allocator_t allocator;
  void * state;
} rcutils_dir_iter_t;


RCUTILS_PUBLIC
rcutils_dir_iter_t *
rcutils_dir_iter_start(const char * directory_path, const rcutils_allocator_t allocator);


RCUTILS_PUBLIC
bool
rcutils_dir_iter_next(rcutils_dir_iter_t * iter);


RCUTILS_PUBLIC
void
rcutils_dir_iter_end(rcutils_dir_iter_t * iter);

#ifdef __cplusplus
}
#endif

#endif  // RCUTILS__FILESYSTEM_H_