logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/

fs.h (1288B)


  1. // utils-std: Collection of commonly available Unix tools
  2. // SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. // SPDX-License-Identifier: MPL-2.0
  4. #include "../config.h" // HAS_*
  5. #include <stdbool.h>
  6. #include <stddef.h> // size_t
  7. #include <stdio.h> // off_t
  8. // barebones basename, returns what's after the rightmost slash
  9. char *static_basename(char *path);
  10. // Modifies a path in-place to given a parent (dirname-like) and a child (basename-like)
  11. // optionally trims the tailing slashes prior to splitting
  12. char *path_split_static(char *path, bool trim);
  13. // Copy data from fd_in to fd_out, with a max of len (flag is ignored for now)
  14. ssize_t manual_file_copy(int fd_in, int fd_out, off_t len, int flags);
  15. #ifndef HAS_COPY_FILE_RANGE
  16. #define auto_file_copy manual_file_copy
  17. #else
  18. // Copy data with copy_file_range(2) for <len> amount of data, with fallback to manual_file_copy when cross-device
  19. ssize_t auto_file_copy(int fd_in, int fd_out, off_t len, int flags);
  20. #endif
  21. #ifndef HAS_SENDFILE
  22. #define auto_fd_copy(fd_in, fd_out, len) auto_file_copy(fd_in, fd_out, len, 0)
  23. #else
  24. ssize_t auto_fd_copy(int fd_in, int fd_out, size_t len);
  25. #endif
  26. // lib/offline_realpath.c
  27. char *offline_realpath(const char *restrict filename, char *restrict resolved);