logo

utils-std

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

fs.h (1255B)


  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 <stdbool.h>
  5. #include <stddef.h> // size_t
  6. #include <stdio.h> // off_t
  7. // barebones basename, returns what's after the rightmost slash
  8. char *static_basename(char *path);
  9. // Modifies a path in-place to given a parent (dirname-like) and a child (basename-like)
  10. // optionally trims the tailing slashes prior to splitting
  11. char *path_split_static(char *path, bool trim);
  12. // Copy data from fd_in to fd_out, with a max of len (flag is ignored for now)
  13. ssize_t manual_file_copy(int fd_in, int fd_out, off_t len, int flags);
  14. #ifndef HAS_COPY_FILE_RANGE
  15. #define auto_file_copy manual_file_copy
  16. #else
  17. // Copy data with copy_file_range(2) for <len> amount of data, with fallback to manual_file_copy when cross-device
  18. ssize_t auto_file_copy(int fd_in, int fd_out, off_t len, int flags);
  19. #endif
  20. #ifndef HAS_SENDFILE
  21. #define auto_fd_copy(fd_in, fd_out, len) auto_file_copy(fd_in, fd_out, len, 0)
  22. #else
  23. ssize_t auto_fd_copy(int fd_in, int fd_out, size_t len);
  24. #endif
  25. // lib/offline_realpath.c
  26. char *offline_realpath(const char *restrict filename, char *restrict resolved);