1cef8759bSmrg // Filesystem operational functions -*- C++ -*-
2cef8759bSmrg
3*4c3eb207Smrg // Copyright (C) 2014-2020 Free Software Foundation, Inc.
4cef8759bSmrg //
5cef8759bSmrg // This file is part of the GNU ISO C++ Library. This library is free
6cef8759bSmrg // software; you can redistribute it and/or modify it under the
7cef8759bSmrg // terms of the GNU General Public License as published by the
8cef8759bSmrg // Free Software Foundation; either version 3, or (at your __option)
9cef8759bSmrg // any later version.
10cef8759bSmrg
11cef8759bSmrg // This library is distributed in the hope that it will be useful,
12cef8759bSmrg // but WITHOUT ANY WARRANTY; without even the implied warranty of
13cef8759bSmrg // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14cef8759bSmrg // GNU General Public License for more details.
15cef8759bSmrg
16cef8759bSmrg // Under Section 7 of GPL version 3, you are granted additional
17cef8759bSmrg // permissions described in the GCC Runtime Library Exception, version
18cef8759bSmrg // 3.1, as published by the Free Software Foundation.
19cef8759bSmrg
20cef8759bSmrg // You should have received a copy of the GNU General Public License and
21cef8759bSmrg // a copy of the GCC Runtime Library Exception along with this program;
22cef8759bSmrg // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23cef8759bSmrg // <http://www.gnu.org/licenses/>.
24cef8759bSmrg
25*4c3eb207Smrg /** @file include/bits/fs_ops.h
26cef8759bSmrg * This is an internal header file, included by other library headers.
27cef8759bSmrg * Do not attempt to use it directly. @headername{filesystem}
28cef8759bSmrg */
29cef8759bSmrg
30cef8759bSmrg #ifndef _GLIBCXX_FS_OPS_H
31cef8759bSmrg #define _GLIBCXX_FS_OPS_H 1
32cef8759bSmrg
33cef8759bSmrg #if __cplusplus >= 201703L
34cef8759bSmrg
35cef8759bSmrg #include <cstdint>
36cef8759bSmrg
_GLIBCXX_VISIBILITY(default)37cef8759bSmrg namespace std _GLIBCXX_VISIBILITY(default)
38cef8759bSmrg {
39cef8759bSmrg _GLIBCXX_BEGIN_NAMESPACE_VERSION
40cef8759bSmrg
41cef8759bSmrg namespace filesystem
42cef8759bSmrg {
43*4c3eb207Smrg /** @addtogroup filesystem
44cef8759bSmrg * @{
45cef8759bSmrg */
46cef8759bSmrg
47cef8759bSmrg path absolute(const path& __p);
48cef8759bSmrg path absolute(const path& __p, error_code& __ec);
49cef8759bSmrg
50cef8759bSmrg path canonical(const path& __p);
51cef8759bSmrg path canonical(const path& __p, error_code& __ec);
52cef8759bSmrg
53cef8759bSmrg inline void
54cef8759bSmrg copy(const path& __from, const path& __to)
55cef8759bSmrg { copy(__from, __to, copy_options::none); }
56cef8759bSmrg
57cef8759bSmrg inline void
58cef8759bSmrg copy(const path& __from, const path& __to, error_code& __ec)
59cef8759bSmrg { copy(__from, __to, copy_options::none, __ec); }
60cef8759bSmrg
61cef8759bSmrg void copy(const path& __from, const path& __to, copy_options __options);
62cef8759bSmrg void copy(const path& __from, const path& __to, copy_options __options,
63cef8759bSmrg error_code& __ec);
64cef8759bSmrg
65cef8759bSmrg inline bool
66cef8759bSmrg copy_file(const path& __from, const path& __to)
67cef8759bSmrg { return copy_file(__from, __to, copy_options::none); }
68cef8759bSmrg
69cef8759bSmrg inline bool
70cef8759bSmrg copy_file(const path& __from, const path& __to, error_code& __ec)
71cef8759bSmrg { return copy_file(__from, __to, copy_options::none, __ec); }
72cef8759bSmrg
73cef8759bSmrg bool copy_file(const path& __from, const path& __to, copy_options __option);
74cef8759bSmrg bool copy_file(const path& __from, const path& __to, copy_options __option,
75cef8759bSmrg error_code& __ec);
76cef8759bSmrg
77cef8759bSmrg void copy_symlink(const path& __existing_symlink, const path& __new_symlink);
78cef8759bSmrg void copy_symlink(const path& __existing_symlink, const path& __new_symlink,
79cef8759bSmrg error_code& __ec) noexcept;
80cef8759bSmrg
81cef8759bSmrg bool create_directories(const path& __p);
82cef8759bSmrg bool create_directories(const path& __p, error_code& __ec);
83cef8759bSmrg
84cef8759bSmrg bool create_directory(const path& __p);
85cef8759bSmrg bool create_directory(const path& __p, error_code& __ec) noexcept;
86cef8759bSmrg
87cef8759bSmrg bool create_directory(const path& __p, const path& attributes);
88cef8759bSmrg bool create_directory(const path& __p, const path& attributes,
89cef8759bSmrg error_code& __ec) noexcept;
90cef8759bSmrg
91cef8759bSmrg void create_directory_symlink(const path& __to, const path& __new_symlink);
92cef8759bSmrg void create_directory_symlink(const path& __to, const path& __new_symlink,
93cef8759bSmrg error_code& __ec) noexcept;
94cef8759bSmrg
95cef8759bSmrg void create_hard_link(const path& __to, const path& __new_hard_link);
96cef8759bSmrg void create_hard_link(const path& __to, const path& __new_hard_link,
97cef8759bSmrg error_code& __ec) noexcept;
98cef8759bSmrg
99cef8759bSmrg void create_symlink(const path& __to, const path& __new_symlink);
100cef8759bSmrg void create_symlink(const path& __to, const path& __new_symlink,
101cef8759bSmrg error_code& __ec) noexcept;
102cef8759bSmrg
103cef8759bSmrg path current_path();
104cef8759bSmrg path current_path(error_code& __ec);
105cef8759bSmrg void current_path(const path& __p);
106cef8759bSmrg void current_path(const path& __p, error_code& __ec) noexcept;
107cef8759bSmrg
108cef8759bSmrg bool
109cef8759bSmrg equivalent(const path& __p1, const path& __p2);
110cef8759bSmrg
111cef8759bSmrg bool
112cef8759bSmrg equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept;
113cef8759bSmrg
114cef8759bSmrg inline bool
115cef8759bSmrg exists(file_status __s) noexcept
116cef8759bSmrg { return status_known(__s) && __s.type() != file_type::not_found; }
117cef8759bSmrg
118cef8759bSmrg inline bool
119cef8759bSmrg exists(const path& __p)
120cef8759bSmrg { return exists(status(__p)); }
121cef8759bSmrg
122cef8759bSmrg inline bool
123cef8759bSmrg exists(const path& __p, error_code& __ec) noexcept
124cef8759bSmrg {
125cef8759bSmrg auto __s = status(__p, __ec);
126cef8759bSmrg if (status_known(__s))
127cef8759bSmrg {
128cef8759bSmrg __ec.clear();
129cef8759bSmrg return __s.type() != file_type::not_found;
130cef8759bSmrg }
131cef8759bSmrg return false;
132cef8759bSmrg }
133cef8759bSmrg
134cef8759bSmrg uintmax_t file_size(const path& __p);
135cef8759bSmrg uintmax_t file_size(const path& __p, error_code& __ec) noexcept;
136cef8759bSmrg
137cef8759bSmrg uintmax_t hard_link_count(const path& __p);
138cef8759bSmrg uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept;
139cef8759bSmrg
140cef8759bSmrg inline bool
141cef8759bSmrg is_block_file(file_status __s) noexcept
142cef8759bSmrg { return __s.type() == file_type::block; }
143cef8759bSmrg
144cef8759bSmrg inline bool
145cef8759bSmrg is_block_file(const path& __p)
146cef8759bSmrg { return is_block_file(status(__p)); }
147cef8759bSmrg
148cef8759bSmrg inline bool
149cef8759bSmrg is_block_file(const path& __p, error_code& __ec) noexcept
150cef8759bSmrg { return is_block_file(status(__p, __ec)); }
151cef8759bSmrg
152cef8759bSmrg inline bool
153cef8759bSmrg is_character_file(file_status __s) noexcept
154cef8759bSmrg { return __s.type() == file_type::character; }
155cef8759bSmrg
156cef8759bSmrg inline bool
157cef8759bSmrg is_character_file(const path& __p)
158cef8759bSmrg { return is_character_file(status(__p)); }
159cef8759bSmrg
160cef8759bSmrg inline bool
161cef8759bSmrg is_character_file(const path& __p, error_code& __ec) noexcept
162cef8759bSmrg { return is_character_file(status(__p, __ec)); }
163cef8759bSmrg
164cef8759bSmrg inline bool
165cef8759bSmrg is_directory(file_status __s) noexcept
166cef8759bSmrg { return __s.type() == file_type::directory; }
167cef8759bSmrg
168cef8759bSmrg inline bool
169cef8759bSmrg is_directory(const path& __p)
170cef8759bSmrg { return is_directory(status(__p)); }
171cef8759bSmrg
172cef8759bSmrg inline bool
173cef8759bSmrg is_directory(const path& __p, error_code& __ec) noexcept
174cef8759bSmrg { return is_directory(status(__p, __ec)); }
175cef8759bSmrg
176cef8759bSmrg bool is_empty(const path& __p);
177cef8759bSmrg bool is_empty(const path& __p, error_code& __ec);
178cef8759bSmrg
179cef8759bSmrg inline bool
180cef8759bSmrg is_fifo(file_status __s) noexcept
181cef8759bSmrg { return __s.type() == file_type::fifo; }
182cef8759bSmrg
183cef8759bSmrg inline bool
184cef8759bSmrg is_fifo(const path& __p)
185cef8759bSmrg { return is_fifo(status(__p)); }
186cef8759bSmrg
187cef8759bSmrg inline bool
188cef8759bSmrg is_fifo(const path& __p, error_code& __ec) noexcept
189cef8759bSmrg { return is_fifo(status(__p, __ec)); }
190cef8759bSmrg
191cef8759bSmrg inline bool
192cef8759bSmrg is_other(file_status __s) noexcept
193cef8759bSmrg {
194cef8759bSmrg return exists(__s) && !is_regular_file(__s) && !is_directory(__s)
195cef8759bSmrg && !is_symlink(__s);
196cef8759bSmrg }
197cef8759bSmrg
198cef8759bSmrg inline bool
199cef8759bSmrg is_other(const path& __p)
200cef8759bSmrg { return is_other(status(__p)); }
201cef8759bSmrg
202cef8759bSmrg inline bool
203cef8759bSmrg is_other(const path& __p, error_code& __ec) noexcept
204cef8759bSmrg { return is_other(status(__p, __ec)); }
205cef8759bSmrg
206cef8759bSmrg inline bool
207cef8759bSmrg is_regular_file(file_status __s) noexcept
208cef8759bSmrg { return __s.type() == file_type::regular; }
209cef8759bSmrg
210cef8759bSmrg inline bool
211cef8759bSmrg is_regular_file(const path& __p)
212cef8759bSmrg { return is_regular_file(status(__p)); }
213cef8759bSmrg
214cef8759bSmrg inline bool
215cef8759bSmrg is_regular_file(const path& __p, error_code& __ec) noexcept
216cef8759bSmrg { return is_regular_file(status(__p, __ec)); }
217cef8759bSmrg
218cef8759bSmrg inline bool
219cef8759bSmrg is_socket(file_status __s) noexcept
220cef8759bSmrg { return __s.type() == file_type::socket; }
221cef8759bSmrg
222cef8759bSmrg inline bool
223cef8759bSmrg is_socket(const path& __p)
224cef8759bSmrg { return is_socket(status(__p)); }
225cef8759bSmrg
226cef8759bSmrg inline bool
227cef8759bSmrg is_socket(const path& __p, error_code& __ec) noexcept
228cef8759bSmrg { return is_socket(status(__p, __ec)); }
229cef8759bSmrg
230cef8759bSmrg inline bool
231cef8759bSmrg is_symlink(file_status __s) noexcept
232cef8759bSmrg { return __s.type() == file_type::symlink; }
233cef8759bSmrg
234cef8759bSmrg inline bool
235cef8759bSmrg is_symlink(const path& __p)
236cef8759bSmrg { return is_symlink(symlink_status(__p)); }
237cef8759bSmrg
238cef8759bSmrg inline bool
239cef8759bSmrg is_symlink(const path& __p, error_code& __ec) noexcept
240cef8759bSmrg { return is_symlink(symlink_status(__p, __ec)); }
241cef8759bSmrg
242cef8759bSmrg file_time_type last_write_time(const path& __p);
243cef8759bSmrg file_time_type last_write_time(const path& __p, error_code& __ec) noexcept;
244cef8759bSmrg void last_write_time(const path& __p, file_time_type __new_time);
245cef8759bSmrg void last_write_time(const path& __p, file_time_type __new_time,
246cef8759bSmrg error_code& __ec) noexcept;
247cef8759bSmrg
248cef8759bSmrg void
249cef8759bSmrg permissions(const path& __p, perms __prms,
250cef8759bSmrg perm_options __opts = perm_options::replace);
251cef8759bSmrg
252cef8759bSmrg inline void
253cef8759bSmrg permissions(const path& __p, perms __prms, error_code& __ec) noexcept
254cef8759bSmrg { permissions(__p, __prms, perm_options::replace, __ec); }
255cef8759bSmrg
256cef8759bSmrg void
257cef8759bSmrg permissions(const path& __p, perms __prms, perm_options __opts,
258cef8759bSmrg error_code& __ec) noexcept;
259cef8759bSmrg
260cef8759bSmrg inline path proximate(const path& __p, error_code& __ec)
261cef8759bSmrg { return proximate(__p, current_path(), __ec); }
262cef8759bSmrg
263cef8759bSmrg path proximate(const path& __p, const path& __base = current_path());
264cef8759bSmrg path proximate(const path& __p, const path& __base, error_code& __ec);
265cef8759bSmrg
266cef8759bSmrg path read_symlink(const path& __p);
267cef8759bSmrg path read_symlink(const path& __p, error_code& __ec);
268cef8759bSmrg
269cef8759bSmrg inline path relative(const path& __p, error_code& __ec)
270cef8759bSmrg { return relative(__p, current_path(), __ec); }
271cef8759bSmrg
272cef8759bSmrg path relative(const path& __p, const path& __base = current_path());
273cef8759bSmrg path relative(const path& __p, const path& __base, error_code& __ec);
274cef8759bSmrg
275cef8759bSmrg bool remove(const path& __p);
276cef8759bSmrg bool remove(const path& __p, error_code& __ec) noexcept;
277cef8759bSmrg
278cef8759bSmrg uintmax_t remove_all(const path& __p);
279cef8759bSmrg uintmax_t remove_all(const path& __p, error_code& __ec);
280cef8759bSmrg
281cef8759bSmrg void rename(const path& __from, const path& __to);
282cef8759bSmrg void rename(const path& __from, const path& __to, error_code& __ec) noexcept;
283cef8759bSmrg
284cef8759bSmrg void resize_file(const path& __p, uintmax_t __size);
285cef8759bSmrg void resize_file(const path& __p, uintmax_t __size, error_code& __ec) noexcept;
286cef8759bSmrg
287cef8759bSmrg space_info space(const path& __p);
288cef8759bSmrg space_info space(const path& __p, error_code& __ec) noexcept;
289cef8759bSmrg
290cef8759bSmrg file_status status(const path& __p);
291cef8759bSmrg file_status status(const path& __p, error_code& __ec) noexcept;
292cef8759bSmrg
293cef8759bSmrg inline bool status_known(file_status __s) noexcept
294cef8759bSmrg { return __s.type() != file_type::none; }
295cef8759bSmrg
296cef8759bSmrg file_status symlink_status(const path& __p);
297cef8759bSmrg file_status symlink_status(const path& __p, error_code& __ec) noexcept;
298cef8759bSmrg
299cef8759bSmrg path temp_directory_path();
300cef8759bSmrg path temp_directory_path(error_code& __ec);
301cef8759bSmrg
302cef8759bSmrg path weakly_canonical(const path& __p);
303cef8759bSmrg path weakly_canonical(const path& __p, error_code& __ec);
304cef8759bSmrg
305*4c3eb207Smrg /// @} group filesystem
306cef8759bSmrg } // namespace filesystem
307cef8759bSmrg
308cef8759bSmrg _GLIBCXX_END_NAMESPACE_VERSION
309cef8759bSmrg } // namespace std
310cef8759bSmrg
311cef8759bSmrg #endif // C++17
312cef8759bSmrg
313cef8759bSmrg #endif // _GLIBCXX_FS_OPS_H
314