1 // Filesystem operational functions -*- C++ -*-
3 // Copyright (C) 2014-2023 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your __option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
25 /** @file experimental/bits/fs_ops.h
26 * This is an internal header file, included by other library headers.
27 * Do not attempt to use it directly. @headername{experimental/filesystem}
30 #ifndef _GLIBCXX_EXPERIMENTAL_FS_OPS_H
31 #define _GLIBCXX_EXPERIMENTAL_FS_OPS_H 1
33 #if __cplusplus < 201103L
34 # include <bits/c++0x_warning.h>
39 namespace std
_GLIBCXX_VISIBILITY(default)
41 _GLIBCXX_BEGIN_NAMESPACE_VERSION
43 namespace experimental
50 * @addtogroup filesystem-ts
55 path
absolute(const path
& __p
, const path
& __base
= current_path());
58 path
canonical(const path
& __p
, const path
& __base
= current_path());
61 path
canonical(const path
& __p
, error_code
& __ec
);
64 path
canonical(const path
& __p
, const path
& __base
, error_code
& __ec
);
67 copy(const path
& __from
, const path
& __to
)
68 { copy(__from
, __to
, copy_options::none
); }
71 copy(const path
& __from
, const path
& __to
, error_code
& __ec
) noexcept
72 { copy(__from
, __to
, copy_options::none
, __ec
); }
74 void copy(const path
& __from
, const path
& __to
, copy_options __options
);
76 void copy(const path
& __from
, const path
& __to
, copy_options __options
,
77 error_code
& __ec
) noexcept
;
80 copy_file(const path
& __from
, const path
& __to
)
81 { return copy_file(__from
, __to
, copy_options::none
); }
84 copy_file(const path
& __from
, const path
& __to
, error_code
& __ec
)
85 { return copy_file(__from
, __to
, copy_options::none
, __ec
); }
87 bool copy_file(const path
& __from
, const path
& __to
, copy_options __option
);
88 bool copy_file(const path
& __from
, const path
& __to
, copy_options __option
,
91 void copy_symlink(const path
& __existing_symlink
, const path
& __new_symlink
);
92 void copy_symlink(const path
& __existing_symlink
, const path
& __new_symlink
,
93 error_code
& __ec
) noexcept
;
95 bool create_directories(const path
& __p
);
96 bool create_directories(const path
& __p
, error_code
& __ec
);
98 bool create_directory(const path
& __p
);
99 bool create_directory(const path
& __p
, error_code
& __ec
) noexcept
;
101 bool create_directory(const path
& __p
, const path
& attributes
);
102 bool create_directory(const path
& __p
, const path
& attributes
,
103 error_code
& __ec
) noexcept
;
105 void create_directory_symlink(const path
& __to
, const path
& __new_symlink
);
106 void create_directory_symlink(const path
& __to
, const path
& __new_symlink
,
107 error_code
& __ec
) noexcept
;
109 void create_hard_link(const path
& __to
, const path
& __new_hard_link
);
110 void create_hard_link(const path
& __to
, const path
& __new_hard_link
,
111 error_code
& __ec
) noexcept
;
113 void create_symlink(const path
& __to
, const path
& __new_symlink
);
114 void create_symlink(const path
& __to
, const path
& __new_symlink
,
115 error_code
& __ec
) noexcept
;
121 path
current_path(error_code
& __ec
);
123 void current_path(const path
& __p
);
124 void current_path(const path
& __p
, error_code
& __ec
) noexcept
;
128 equivalent(const path
& __p1
, const path
& __p2
);
132 equivalent(const path
& __p1
, const path
& __p2
, error_code
& __ec
) noexcept
;
136 exists(file_status __s
) noexcept
137 { return status_known(__s
) && __s
.type() != file_type::not_found
; }
141 exists(const path
& __p
)
142 { return exists(status(__p
)); }
146 exists(const path
& __p
, error_code
& __ec
) noexcept
148 auto __s
= status(__p
, __ec
);
149 if (status_known(__s
))
152 return __s
.type() != file_type::not_found
;
158 uintmax_t file_size(const path
& __p
);
161 uintmax_t file_size(const path
& __p
, error_code
& __ec
) noexcept
;
164 uintmax_t hard_link_count(const path
& __p
);
167 uintmax_t hard_link_count(const path
& __p
, error_code
& __ec
) noexcept
;
171 is_block_file(file_status __s
) noexcept
172 { return __s
.type() == file_type::block
; }
176 is_block_file(const path
& __p
)
177 { return is_block_file(status(__p
)); }
181 is_block_file(const path
& __p
, error_code
& __ec
) noexcept
182 { return is_block_file(status(__p
, __ec
)); }
186 is_character_file(file_status __s
) noexcept
187 { return __s
.type() == file_type::character
; }
191 is_character_file(const path
& __p
)
192 { return is_character_file(status(__p
)); }
196 is_character_file(const path
& __p
, error_code
& __ec
) noexcept
197 { return is_character_file(status(__p
, __ec
)); }
201 is_directory(file_status __s
) noexcept
202 { return __s
.type() == file_type::directory
; }
206 is_directory(const path
& __p
)
207 { return is_directory(status(__p
)); }
211 is_directory(const path
& __p
, error_code
& __ec
) noexcept
212 { return is_directory(status(__p
, __ec
)); }
215 bool is_empty(const path
& __p
);
217 bool is_empty(const path
& __p
, error_code
& __ec
) noexcept
;
221 is_fifo(file_status __s
) noexcept
222 { return __s
.type() == file_type::fifo
; }
226 is_fifo(const path
& __p
)
227 { return is_fifo(status(__p
)); }
231 is_fifo(const path
& __p
, error_code
& __ec
) noexcept
232 { return is_fifo(status(__p
, __ec
)); }
236 is_other(file_status __s
) noexcept
238 return exists(__s
) && !is_regular_file(__s
) && !is_directory(__s
)
244 is_other(const path
& __p
)
245 { return is_other(status(__p
)); }
249 is_other(const path
& __p
, error_code
& __ec
) noexcept
250 { return is_other(status(__p
, __ec
)); }
254 is_regular_file(file_status __s
) noexcept
255 { return __s
.type() == file_type::regular
; }
259 is_regular_file(const path
& __p
)
260 { return is_regular_file(status(__p
)); }
264 is_regular_file(const path
& __p
, error_code
& __ec
) noexcept
265 { return is_regular_file(status(__p
, __ec
)); }
269 is_socket(file_status __s
) noexcept
270 { return __s
.type() == file_type::socket
; }
274 is_socket(const path
& __p
)
275 { return is_socket(status(__p
)); }
279 is_socket(const path
& __p
, error_code
& __ec
) noexcept
280 { return is_socket(status(__p
, __ec
)); }
284 is_symlink(file_status __s
) noexcept
285 { return __s
.type() == file_type::symlink
; }
289 is_symlink(const path
& __p
)
290 { return is_symlink(symlink_status(__p
)); }
294 is_symlink(const path
& __p
, error_code
& __ec
) noexcept
295 { return is_symlink(symlink_status(__p
, __ec
)); }
298 file_time_type
last_write_time(const path
& __p
);
301 file_time_type
last_write_time(const path
& __p
, error_code
& __ec
) noexcept
;
303 void last_write_time(const path
& __p
, file_time_type __new_time
);
304 void last_write_time(const path
& __p
, file_time_type __new_time
,
305 error_code
& __ec
) noexcept
;
307 void permissions(const path
& __p
, perms __prms
);
308 void permissions(const path
& __p
, perms __prms
, error_code
& __ec
) noexcept
;
311 path
read_symlink(const path
& __p
);
314 path
read_symlink(const path
& __p
, error_code
& __ec
);
316 bool remove(const path
& __p
);
317 bool remove(const path
& __p
, error_code
& __ec
) noexcept
;
319 uintmax_t remove_all(const path
& __p
);
320 uintmax_t remove_all(const path
& __p
, error_code
& __ec
);
322 void rename(const path
& __from
, const path
& __to
);
323 void rename(const path
& __from
, const path
& __to
, error_code
& __ec
) noexcept
;
325 void resize_file(const path
& __p
, uintmax_t __size
);
326 void resize_file(const path
& __p
, uintmax_t __size
, error_code
& __ec
) noexcept
;
329 space_info
space(const path
& __p
);
332 space_info
space(const path
& __p
, error_code
& __ec
) noexcept
;
335 file_status
status(const path
& __p
);
338 file_status
status(const path
& __p
, error_code
& __ec
) noexcept
;
341 inline bool status_known(file_status __s
) noexcept
342 { return __s
.type() != file_type::none
; }
345 file_status
symlink_status(const path
& __p
);
348 file_status
symlink_status(const path
& __p
, error_code
& __ec
) noexcept
;
351 path
system_complete(const path
& __p
);
354 path
system_complete(const path
& __p
, error_code
& __ec
);
357 path
temp_directory_path();
360 path
temp_directory_path(error_code
& __ec
);
362 /// @} group filesystem-ts
364 } // namespace filesystem
365 } // namespace experimental
367 _GLIBCXX_END_NAMESPACE_VERSION
372 #endif // _GLIBCXX_EXPERIMENTAL_FS_OPS_H