1 | // posix_tools.hpp -------------------------------------------------------------------// |
2 | |
3 | // Copyright 2021-2024 Andrey Semashev |
4 | |
5 | // Distributed under the Boost Software License, Version 1.0. |
6 | // See http://www.boost.org/LICENSE_1_0.txt |
7 | |
8 | // See library home page at http://www.boost.org/libs/filesystem |
9 | |
10 | //--------------------------------------------------------------------------------------// |
11 | |
12 | #ifndef BOOST_FILESYSTEM_SRC_POSIX_TOOLS_HPP_ |
13 | #define BOOST_FILESYSTEM_SRC_POSIX_TOOLS_HPP_ |
14 | |
15 | #include "platform_config.hpp" |
16 | #include <boost/filesystem/config.hpp> |
17 | #include <unistd.h> |
18 | #include <fcntl.h> |
19 | |
20 | #include <boost/scope/unique_fd.hpp> |
21 | #include <boost/system/error_code.hpp> |
22 | #include <boost/filesystem/path.hpp> |
23 | #include <boost/filesystem/file_status.hpp> |
24 | #include <boost/filesystem/directory.hpp> |
25 | #include <boost/filesystem/detail/header.hpp> // must be the last #include |
26 | |
27 | namespace boost { |
28 | namespace filesystem { |
29 | namespace detail { |
30 | |
31 | //! Platform-specific parameters for directory iterator construction |
32 | struct directory_iterator_params |
33 | { |
34 | #if defined(BOOST_FILESYSTEM_HAS_FDOPENDIR_NOFOLLOW) |
35 | //! File descriptor of the directory to iterate over. If not a negative value, the directory path is only used to generate paths returned by the iterator. |
36 | boost::scope::unique_fd dir_fd; |
37 | #endif |
38 | }; |
39 | |
40 | //! status() implementation |
41 | file_status status_impl |
42 | ( |
43 | path const& p, |
44 | system::error_code* ec |
45 | #if defined(BOOST_FILESYSTEM_HAS_POSIX_AT_APIS) || defined(BOOST_FILESYSTEM_USE_STATX) |
46 | , int basedir_fd = AT_FDCWD |
47 | #endif |
48 | ); |
49 | |
50 | //! symlink_status() implementation |
51 | file_status symlink_status_impl |
52 | ( |
53 | path const& p, |
54 | system::error_code* ec |
55 | #if defined(BOOST_FILESYSTEM_HAS_POSIX_AT_APIS) || defined(BOOST_FILESYSTEM_USE_STATX) |
56 | , int basedir_fd = AT_FDCWD |
57 | #endif |
58 | ); |
59 | |
60 | #if defined(BOOST_POSIX_API) |
61 | |
62 | //! Opens a directory file and returns a file descriptor. Returns a negative value in case of error. |
63 | boost::scope::unique_fd open_directory(path const& p, directory_options opts, system::error_code& ec); |
64 | |
65 | #if defined(BOOST_FILESYSTEM_HAS_POSIX_AT_APIS) |
66 | //! Opens a directory file and returns a file descriptor. Returns a negative value in case of error. |
67 | boost::scope::unique_fd openat_directory(int basedir_fd, path const& p, directory_options opts, system::error_code& ec); |
68 | #endif // defined(BOOST_FILESYSTEM_HAS_POSIX_AT_APIS) |
69 | |
70 | #endif // defined(BOOST_POSIX_API) |
71 | |
72 | } // namespace detail |
73 | } // namespace filesystem |
74 | } // namespace boost |
75 | |
76 | #include <boost/filesystem/detail/footer.hpp> |
77 | |
78 | #endif // BOOST_FILESYSTEM_SRC_POSIX_TOOLS_HPP_ |
79 | |