xref: /netbsd-src/external/gpl3/gcc.old/dist/libstdc++-v3/include/experimental/bits/fs_ops.h (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
136ac495dSmrg // Filesystem operational functions -*- C++ -*-
236ac495dSmrg 
3*8feb0f0bSmrg // Copyright (C) 2014-2020 Free Software Foundation, Inc.
436ac495dSmrg //
536ac495dSmrg // This file is part of the GNU ISO C++ Library.  This library is free
636ac495dSmrg // software; you can redistribute it and/or modify it under the
736ac495dSmrg // terms of the GNU General Public License as published by the
836ac495dSmrg // Free Software Foundation; either version 3, or (at your __option)
936ac495dSmrg // any later version.
1036ac495dSmrg 
1136ac495dSmrg // This library is distributed in the hope that it will be useful,
1236ac495dSmrg // but WITHOUT ANY WARRANTY; without even the implied warranty of
1336ac495dSmrg // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1436ac495dSmrg // GNU General Public License for more details.
1536ac495dSmrg 
1636ac495dSmrg // Under Section 7 of GPL version 3, you are granted additional
1736ac495dSmrg // permissions described in the GCC Runtime Library Exception, version
1836ac495dSmrg // 3.1, as published by the Free Software Foundation.
1936ac495dSmrg 
2036ac495dSmrg // You should have received a copy of the GNU General Public License and
2136ac495dSmrg // a copy of the GCC Runtime Library Exception along with this program;
2236ac495dSmrg // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
2336ac495dSmrg // <http://www.gnu.org/licenses/>.
2436ac495dSmrg 
25*8feb0f0bSmrg /** @file experimental/bits/fs_ops.h
2636ac495dSmrg  *  This is an internal header file, included by other library headers.
2736ac495dSmrg  *  Do not attempt to use it directly. @headername{experimental/filesystem}
2836ac495dSmrg  */
2936ac495dSmrg 
3036ac495dSmrg #ifndef _GLIBCXX_EXPERIMENTAL_FS_OPS_H
3136ac495dSmrg #define _GLIBCXX_EXPERIMENTAL_FS_OPS_H 1
3236ac495dSmrg 
3336ac495dSmrg #if __cplusplus < 201103L
3436ac495dSmrg # include <bits/c++0x_warning.h>
3536ac495dSmrg #else
3636ac495dSmrg 
3736ac495dSmrg #include <cstdint>
3836ac495dSmrg 
_GLIBCXX_VISIBILITY(default)3936ac495dSmrg namespace std _GLIBCXX_VISIBILITY(default)
4036ac495dSmrg {
41a2dc1f3fSmrg _GLIBCXX_BEGIN_NAMESPACE_VERSION
42a2dc1f3fSmrg 
4336ac495dSmrg namespace experimental
4436ac495dSmrg {
4536ac495dSmrg namespace filesystem
4636ac495dSmrg {
4736ac495dSmrg inline namespace v1
4836ac495dSmrg {
4936ac495dSmrg   /**
50*8feb0f0bSmrg    * @addtogroup filesystem-ts
5136ac495dSmrg    * @{
5236ac495dSmrg    */
5336ac495dSmrg 
5436ac495dSmrg   path absolute(const path& __p, const path& __base = current_path());
5536ac495dSmrg 
5636ac495dSmrg   path canonical(const path& __p, const path& __base = current_path());
5736ac495dSmrg   path canonical(const path& __p, error_code& __ec);
5836ac495dSmrg   path canonical(const path& __p, const path& __base, error_code& __ec);
5936ac495dSmrg 
6036ac495dSmrg   inline void
6136ac495dSmrg   copy(const path& __from, const path& __to)
6236ac495dSmrg   { copy(__from, __to, copy_options::none); }
6336ac495dSmrg 
6436ac495dSmrg   inline void
6536ac495dSmrg   copy(const path& __from, const path& __to, error_code& __ec) noexcept
6636ac495dSmrg   { copy(__from, __to, copy_options::none, __ec); }
6736ac495dSmrg 
6836ac495dSmrg   void copy(const path& __from, const path& __to, copy_options __options);
6936ac495dSmrg   void copy(const path& __from, const path& __to, copy_options __options,
7036ac495dSmrg 	    error_code& __ec) noexcept;
7136ac495dSmrg 
7236ac495dSmrg   inline bool
7336ac495dSmrg   copy_file(const path& __from, const path& __to)
7436ac495dSmrg   { return copy_file(__from, __to, copy_options::none); }
7536ac495dSmrg 
7636ac495dSmrg   inline bool
77*8feb0f0bSmrg   copy_file(const path& __from, const path& __to, error_code& __ec)
7836ac495dSmrg   { return copy_file(__from, __to, copy_options::none, __ec); }
7936ac495dSmrg 
8036ac495dSmrg   bool copy_file(const path& __from, const path& __to, copy_options __option);
8136ac495dSmrg   bool copy_file(const path& __from, const path& __to, copy_options __option,
82*8feb0f0bSmrg 		 error_code& __ec);
8336ac495dSmrg 
8436ac495dSmrg   void copy_symlink(const path& __existing_symlink, const path& __new_symlink);
8536ac495dSmrg   void copy_symlink(const path& __existing_symlink, const path& __new_symlink,
8636ac495dSmrg 		    error_code& __ec) noexcept;
8736ac495dSmrg 
8836ac495dSmrg   bool create_directories(const path& __p);
89*8feb0f0bSmrg   bool create_directories(const path& __p, error_code& __ec);
9036ac495dSmrg 
9136ac495dSmrg   bool create_directory(const path& __p);
9236ac495dSmrg   bool create_directory(const path& __p, error_code& __ec) noexcept;
9336ac495dSmrg 
9436ac495dSmrg   bool create_directory(const path& __p, const path& attributes);
9536ac495dSmrg   bool create_directory(const path& __p, const path& attributes,
9636ac495dSmrg 			error_code& __ec) noexcept;
9736ac495dSmrg 
9836ac495dSmrg   void create_directory_symlink(const path& __to, const path& __new_symlink);
9936ac495dSmrg   void create_directory_symlink(const path& __to, const path& __new_symlink,
10036ac495dSmrg 				error_code& __ec) noexcept;
10136ac495dSmrg 
10236ac495dSmrg   void create_hard_link(const path& __to, const path& __new_hard_link);
10336ac495dSmrg   void create_hard_link(const path& __to, const path& __new_hard_link,
10436ac495dSmrg 			error_code& __ec) noexcept;
10536ac495dSmrg 
10636ac495dSmrg   void create_symlink(const path& __to, const path& __new_symlink);
10736ac495dSmrg   void create_symlink(const path& __to, const path& __new_symlink,
10836ac495dSmrg 		      error_code& __ec) noexcept;
10936ac495dSmrg 
11036ac495dSmrg   path current_path();
11136ac495dSmrg   path current_path(error_code& __ec);
11236ac495dSmrg   void current_path(const path& __p);
11336ac495dSmrg   void current_path(const path& __p, error_code& __ec) noexcept;
11436ac495dSmrg 
11536ac495dSmrg   bool
11636ac495dSmrg   equivalent(const path& __p1, const path& __p2);
11736ac495dSmrg 
11836ac495dSmrg   bool
11936ac495dSmrg   equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept;
12036ac495dSmrg 
12136ac495dSmrg   inline bool
12236ac495dSmrg   exists(file_status __s) noexcept
12336ac495dSmrg   { return status_known(__s) && __s.type() != file_type::not_found; }
12436ac495dSmrg 
12536ac495dSmrg   inline bool
12636ac495dSmrg   exists(const path& __p)
12736ac495dSmrg   { return exists(status(__p)); }
12836ac495dSmrg 
12936ac495dSmrg   inline bool
13036ac495dSmrg   exists(const path& __p, error_code& __ec) noexcept
13136ac495dSmrg   {
13236ac495dSmrg     auto __s = status(__p, __ec);
13336ac495dSmrg     if (status_known(__s))
13436ac495dSmrg       {
13536ac495dSmrg 	__ec.clear();
13636ac495dSmrg 	return __s.type() != file_type::not_found;
13736ac495dSmrg       }
13836ac495dSmrg     return false;
13936ac495dSmrg   }
14036ac495dSmrg 
14136ac495dSmrg   uintmax_t file_size(const path& __p);
14236ac495dSmrg   uintmax_t file_size(const path& __p, error_code& __ec) noexcept;
14336ac495dSmrg 
14436ac495dSmrg   uintmax_t hard_link_count(const path& __p);
14536ac495dSmrg   uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept;
14636ac495dSmrg 
14736ac495dSmrg   inline bool
14836ac495dSmrg   is_block_file(file_status __s) noexcept
14936ac495dSmrg   { return __s.type() == file_type::block; }
15036ac495dSmrg 
15136ac495dSmrg   inline bool
15236ac495dSmrg   is_block_file(const path& __p)
15336ac495dSmrg   { return is_block_file(status(__p)); }
15436ac495dSmrg 
15536ac495dSmrg   inline bool
15636ac495dSmrg   is_block_file(const path& __p, error_code& __ec) noexcept
15736ac495dSmrg   { return is_block_file(status(__p, __ec)); }
15836ac495dSmrg 
15936ac495dSmrg   inline bool
16036ac495dSmrg   is_character_file(file_status __s) noexcept
16136ac495dSmrg   { return __s.type() == file_type::character; }
16236ac495dSmrg 
16336ac495dSmrg   inline bool
16436ac495dSmrg   is_character_file(const path& __p)
16536ac495dSmrg   { return is_character_file(status(__p)); }
16636ac495dSmrg 
16736ac495dSmrg   inline bool
16836ac495dSmrg   is_character_file(const path& __p, error_code& __ec) noexcept
16936ac495dSmrg   { return is_character_file(status(__p, __ec)); }
17036ac495dSmrg 
17136ac495dSmrg   inline bool
17236ac495dSmrg   is_directory(file_status __s) noexcept
17336ac495dSmrg   { return __s.type() == file_type::directory; }
17436ac495dSmrg 
17536ac495dSmrg   inline bool
17636ac495dSmrg   is_directory(const path& __p)
17736ac495dSmrg   { return is_directory(status(__p)); }
17836ac495dSmrg 
17936ac495dSmrg   inline bool
18036ac495dSmrg   is_directory(const path& __p, error_code& __ec) noexcept
18136ac495dSmrg   { return is_directory(status(__p, __ec)); }
18236ac495dSmrg 
18336ac495dSmrg   bool is_empty(const path& __p);
18436ac495dSmrg   bool is_empty(const path& __p, error_code& __ec) noexcept;
18536ac495dSmrg 
18636ac495dSmrg   inline bool
18736ac495dSmrg   is_fifo(file_status __s) noexcept
18836ac495dSmrg   { return __s.type() == file_type::fifo; }
18936ac495dSmrg 
19036ac495dSmrg   inline bool
19136ac495dSmrg   is_fifo(const path& __p)
19236ac495dSmrg   { return is_fifo(status(__p)); }
19336ac495dSmrg 
19436ac495dSmrg   inline bool
19536ac495dSmrg   is_fifo(const path& __p, error_code& __ec) noexcept
19636ac495dSmrg   { return is_fifo(status(__p, __ec)); }
19736ac495dSmrg 
19836ac495dSmrg   inline bool
19936ac495dSmrg   is_other(file_status __s) noexcept
20036ac495dSmrg   {
20136ac495dSmrg     return exists(__s) && !is_regular_file(__s) && !is_directory(__s)
20236ac495dSmrg       && !is_symlink(__s);
20336ac495dSmrg   }
20436ac495dSmrg 
20536ac495dSmrg   inline bool
20636ac495dSmrg   is_other(const path& __p)
20736ac495dSmrg   { return is_other(status(__p)); }
20836ac495dSmrg 
20936ac495dSmrg   inline bool
21036ac495dSmrg   is_other(const path& __p, error_code& __ec) noexcept
21136ac495dSmrg   { return is_other(status(__p, __ec)); }
21236ac495dSmrg 
21336ac495dSmrg   inline bool
21436ac495dSmrg   is_regular_file(file_status __s) noexcept
21536ac495dSmrg   { return __s.type() == file_type::regular; }
21636ac495dSmrg 
21736ac495dSmrg   inline bool
21836ac495dSmrg   is_regular_file(const path& __p)
21936ac495dSmrg   { return is_regular_file(status(__p)); }
22036ac495dSmrg 
22136ac495dSmrg   inline bool
22236ac495dSmrg   is_regular_file(const path& __p, error_code& __ec) noexcept
22336ac495dSmrg   { return is_regular_file(status(__p, __ec)); }
22436ac495dSmrg 
22536ac495dSmrg   inline bool
22636ac495dSmrg   is_socket(file_status __s) noexcept
22736ac495dSmrg   { return __s.type() == file_type::socket; }
22836ac495dSmrg 
22936ac495dSmrg   inline bool
23036ac495dSmrg   is_socket(const path& __p)
23136ac495dSmrg   { return is_socket(status(__p)); }
23236ac495dSmrg 
23336ac495dSmrg   inline bool
23436ac495dSmrg   is_socket(const path& __p, error_code& __ec) noexcept
23536ac495dSmrg   { return is_socket(status(__p, __ec)); }
23636ac495dSmrg 
23736ac495dSmrg   inline bool
23836ac495dSmrg   is_symlink(file_status __s) noexcept
23936ac495dSmrg   { return __s.type() == file_type::symlink; }
24036ac495dSmrg 
24136ac495dSmrg   inline bool
24236ac495dSmrg   is_symlink(const path& __p)
24336ac495dSmrg   { return is_symlink(symlink_status(__p)); }
24436ac495dSmrg 
24536ac495dSmrg   inline bool
24636ac495dSmrg   is_symlink(const path& __p, error_code& __ec) noexcept
24736ac495dSmrg   { return is_symlink(symlink_status(__p, __ec)); }
24836ac495dSmrg 
24936ac495dSmrg   file_time_type  last_write_time(const path& __p);
25036ac495dSmrg   file_time_type  last_write_time(const path& __p, error_code& __ec) noexcept;
25136ac495dSmrg   void last_write_time(const path& __p, file_time_type __new_time);
25236ac495dSmrg   void last_write_time(const path& __p, file_time_type __new_time,
25336ac495dSmrg 		       error_code& __ec) noexcept;
25436ac495dSmrg 
25536ac495dSmrg   void permissions(const path& __p, perms __prms);
25636ac495dSmrg   void permissions(const path& __p, perms __prms, error_code& __ec) noexcept;
25736ac495dSmrg 
25836ac495dSmrg   path read_symlink(const path& __p);
25936ac495dSmrg   path read_symlink(const path& __p, error_code& __ec);
26036ac495dSmrg 
26136ac495dSmrg   bool remove(const path& __p);
26236ac495dSmrg   bool remove(const path& __p, error_code& __ec) noexcept;
26336ac495dSmrg 
26436ac495dSmrg   uintmax_t remove_all(const path& __p);
265*8feb0f0bSmrg   uintmax_t remove_all(const path& __p, error_code& __ec);
26636ac495dSmrg 
26736ac495dSmrg   void rename(const path& __from, const path& __to);
26836ac495dSmrg   void rename(const path& __from, const path& __to, error_code& __ec) noexcept;
26936ac495dSmrg 
27036ac495dSmrg   void resize_file(const path& __p, uintmax_t __size);
27136ac495dSmrg   void resize_file(const path& __p, uintmax_t __size, error_code& __ec) noexcept;
27236ac495dSmrg 
27336ac495dSmrg   space_info space(const path& __p);
27436ac495dSmrg   space_info space(const path& __p, error_code& __ec) noexcept;
27536ac495dSmrg 
27636ac495dSmrg   file_status status(const path& __p);
27736ac495dSmrg   file_status status(const path& __p, error_code& __ec) noexcept;
27836ac495dSmrg 
27936ac495dSmrg   inline bool status_known(file_status __s) noexcept
28036ac495dSmrg   { return __s.type() != file_type::none; }
28136ac495dSmrg 
28236ac495dSmrg   file_status symlink_status(const path& __p);
28336ac495dSmrg   file_status symlink_status(const path& __p, error_code& __ec) noexcept;
28436ac495dSmrg 
28536ac495dSmrg   path system_complete(const path& __p);
28636ac495dSmrg   path system_complete(const path& __p, error_code& __ec);
28736ac495dSmrg 
28836ac495dSmrg   path temp_directory_path();
28936ac495dSmrg   path temp_directory_path(error_code& __ec);
29036ac495dSmrg 
291*8feb0f0bSmrg   /// @} group filesystem-ts
29236ac495dSmrg } // namespace v1
29336ac495dSmrg } // namespace filesystem
29436ac495dSmrg } // namespace experimental
295a2dc1f3fSmrg 
296a2dc1f3fSmrg _GLIBCXX_END_NAMESPACE_VERSION
29736ac495dSmrg } // namespace std
29836ac495dSmrg 
29936ac495dSmrg #endif // C++11
30036ac495dSmrg 
30136ac495dSmrg #endif // _GLIBCXX_EXPERIMENTAL_FS_OPS_H
302