libstdc++
fs_ops.h
00001 // Filesystem operational functions -*- C++ -*-
00002 
00003 // Copyright (C) 2014-2019 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 3, or (at your __option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License and
00021 // a copy of the GCC Runtime Library Exception along with this program;
00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023 // <http://www.gnu.org/licenses/>.
00024 
00025 /** @file include/bits/fs_fwd.h
00026  *  This is an internal header file, included by other library headers.
00027  *  Do not attempt to use it directly. @headername{filesystem}
00028  */
00029 
00030 #ifndef _GLIBCXX_FS_OPS_H
00031 #define _GLIBCXX_FS_OPS_H 1
00032 
00033 #if __cplusplus >= 201703L
00034 
00035 #include <cstdint>
00036 
00037 namespace std _GLIBCXX_VISIBILITY(default)
00038 {
00039 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00040 
00041 namespace filesystem
00042 {
00043   /**
00044    * @ingroup filesystem
00045    * @{
00046    */
00047 
00048   path absolute(const path& __p);
00049   path absolute(const path& __p, error_code& __ec);
00050 
00051   path canonical(const path& __p);
00052   path canonical(const path& __p, error_code& __ec);
00053 
00054   inline void
00055   copy(const path& __from, const path& __to)
00056   { copy(__from, __to, copy_options::none); }
00057 
00058   inline void
00059   copy(const path& __from, const path& __to, error_code& __ec)
00060   { copy(__from, __to, copy_options::none, __ec); }
00061 
00062   void copy(const path& __from, const path& __to, copy_options __options);
00063   void copy(const path& __from, const path& __to, copy_options __options,
00064             error_code& __ec);
00065 
00066   inline bool
00067   copy_file(const path& __from, const path& __to)
00068   { return copy_file(__from, __to, copy_options::none); }
00069 
00070   inline bool
00071   copy_file(const path& __from, const path& __to, error_code& __ec)
00072   { return copy_file(__from, __to, copy_options::none, __ec); }
00073 
00074   bool copy_file(const path& __from, const path& __to, copy_options __option);
00075   bool copy_file(const path& __from, const path& __to, copy_options __option,
00076                  error_code& __ec);
00077 
00078   void copy_symlink(const path& __existing_symlink, const path& __new_symlink);
00079   void copy_symlink(const path& __existing_symlink, const path& __new_symlink,
00080                     error_code& __ec) noexcept;
00081 
00082   bool create_directories(const path& __p);
00083   bool create_directories(const path& __p, error_code& __ec);
00084 
00085   bool create_directory(const path& __p);
00086   bool create_directory(const path& __p, error_code& __ec) noexcept;
00087 
00088   bool create_directory(const path& __p, const path& attributes);
00089   bool create_directory(const path& __p, const path& attributes,
00090                         error_code& __ec) noexcept;
00091 
00092   void create_directory_symlink(const path& __to, const path& __new_symlink);
00093   void create_directory_symlink(const path& __to, const path& __new_symlink,
00094                                 error_code& __ec) noexcept;
00095 
00096   void create_hard_link(const path& __to, const path& __new_hard_link);
00097   void create_hard_link(const path& __to, const path& __new_hard_link,
00098                         error_code& __ec) noexcept;
00099 
00100   void create_symlink(const path& __to, const path& __new_symlink);
00101   void create_symlink(const path& __to, const path& __new_symlink,
00102                       error_code& __ec) noexcept;
00103 
00104   path current_path();
00105   path current_path(error_code& __ec);
00106   void current_path(const path& __p);
00107   void current_path(const path& __p, error_code& __ec) noexcept;
00108 
00109   bool
00110   equivalent(const path& __p1, const path& __p2);
00111 
00112   bool
00113   equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept;
00114 
00115   inline bool
00116   exists(file_status __s) noexcept
00117   { return status_known(__s) && __s.type() != file_type::not_found; }
00118 
00119   inline bool
00120   exists(const path& __p)
00121   { return exists(status(__p)); }
00122 
00123   inline bool
00124   exists(const path& __p, error_code& __ec) noexcept
00125   {
00126     auto __s = status(__p, __ec);
00127     if (status_known(__s))
00128       {
00129         __ec.clear();
00130         return __s.type() != file_type::not_found;
00131       }
00132     return false;
00133   }
00134 
00135   uintmax_t file_size(const path& __p);
00136   uintmax_t file_size(const path& __p, error_code& __ec) noexcept;
00137 
00138   uintmax_t hard_link_count(const path& __p);
00139   uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept;
00140 
00141   inline bool
00142   is_block_file(file_status __s) noexcept
00143   { return __s.type() == file_type::block; }
00144 
00145   inline bool
00146   is_block_file(const path& __p)
00147   { return is_block_file(status(__p)); }
00148 
00149   inline bool
00150   is_block_file(const path& __p, error_code& __ec) noexcept
00151   { return is_block_file(status(__p, __ec)); }
00152 
00153   inline bool
00154   is_character_file(file_status __s) noexcept
00155   { return __s.type() == file_type::character; }
00156 
00157   inline bool
00158   is_character_file(const path& __p)
00159   { return is_character_file(status(__p)); }
00160 
00161   inline bool
00162   is_character_file(const path& __p, error_code& __ec) noexcept
00163   { return is_character_file(status(__p, __ec)); }
00164 
00165   inline bool
00166   is_directory(file_status __s) noexcept
00167   { return __s.type() == file_type::directory; }
00168 
00169   inline bool
00170   is_directory(const path& __p)
00171   { return is_directory(status(__p)); }
00172 
00173   inline bool
00174   is_directory(const path& __p, error_code& __ec) noexcept
00175   { return is_directory(status(__p, __ec)); }
00176 
00177   bool is_empty(const path& __p);
00178   bool is_empty(const path& __p, error_code& __ec);
00179 
00180   inline bool
00181   is_fifo(file_status __s) noexcept
00182   { return __s.type() == file_type::fifo; }
00183 
00184   inline bool
00185   is_fifo(const path& __p)
00186   { return is_fifo(status(__p)); }
00187 
00188   inline bool
00189   is_fifo(const path& __p, error_code& __ec) noexcept
00190   { return is_fifo(status(__p, __ec)); }
00191 
00192   inline bool
00193   is_other(file_status __s) noexcept
00194   {
00195     return exists(__s) && !is_regular_file(__s) && !is_directory(__s)
00196       && !is_symlink(__s);
00197   }
00198 
00199   inline bool
00200   is_other(const path& __p)
00201   { return is_other(status(__p)); }
00202 
00203   inline bool
00204   is_other(const path& __p, error_code& __ec) noexcept
00205   { return is_other(status(__p, __ec)); }
00206 
00207   inline bool
00208   is_regular_file(file_status __s) noexcept
00209   { return __s.type() == file_type::regular; }
00210 
00211   inline bool
00212   is_regular_file(const path& __p)
00213   { return is_regular_file(status(__p)); }
00214 
00215   inline bool
00216   is_regular_file(const path& __p, error_code& __ec) noexcept
00217   { return is_regular_file(status(__p, __ec)); }
00218 
00219   inline bool
00220   is_socket(file_status __s) noexcept
00221   { return __s.type() == file_type::socket; }
00222 
00223   inline bool
00224   is_socket(const path& __p)
00225   { return is_socket(status(__p)); }
00226 
00227   inline bool
00228   is_socket(const path& __p, error_code& __ec) noexcept
00229   { return is_socket(status(__p, __ec)); }
00230 
00231   inline bool
00232   is_symlink(file_status __s) noexcept
00233   { return __s.type() == file_type::symlink; }
00234 
00235   inline bool
00236   is_symlink(const path& __p)
00237   { return is_symlink(symlink_status(__p)); }
00238 
00239   inline bool
00240   is_symlink(const path& __p, error_code& __ec) noexcept
00241   { return is_symlink(symlink_status(__p, __ec)); }
00242 
00243   file_time_type  last_write_time(const path& __p);
00244   file_time_type  last_write_time(const path& __p, error_code& __ec) noexcept;
00245   void last_write_time(const path& __p, file_time_type __new_time);
00246   void last_write_time(const path& __p, file_time_type __new_time,
00247                        error_code& __ec) noexcept;
00248 
00249   void
00250   permissions(const path& __p, perms __prms,
00251               perm_options __opts = perm_options::replace);
00252 
00253   inline void
00254   permissions(const path& __p, perms __prms, error_code& __ec) noexcept
00255   { permissions(__p, __prms, perm_options::replace, __ec); }
00256 
00257   void
00258   permissions(const path& __p, perms __prms, perm_options __opts,
00259               error_code& __ec) noexcept;
00260 
00261   inline path proximate(const path& __p, error_code& __ec)
00262   { return proximate(__p, current_path(), __ec); }
00263 
00264   path proximate(const path& __p, const path& __base = current_path());
00265   path proximate(const path& __p, const path& __base, error_code& __ec);
00266 
00267   path read_symlink(const path& __p);
00268   path read_symlink(const path& __p, error_code& __ec);
00269 
00270   inline path relative(const path& __p, error_code& __ec)
00271   { return relative(__p, current_path(), __ec); }
00272 
00273   path relative(const path& __p, const path& __base = current_path());
00274   path relative(const path& __p, const path& __base, error_code& __ec);
00275 
00276   bool remove(const path& __p);
00277   bool remove(const path& __p, error_code& __ec) noexcept;
00278 
00279   uintmax_t remove_all(const path& __p);
00280   uintmax_t remove_all(const path& __p, error_code& __ec);
00281 
00282   void rename(const path& __from, const path& __to);
00283   void rename(const path& __from, const path& __to, error_code& __ec) noexcept;
00284 
00285   void resize_file(const path& __p, uintmax_t __size);
00286   void resize_file(const path& __p, uintmax_t __size, error_code& __ec) noexcept;
00287 
00288   space_info space(const path& __p);
00289   space_info space(const path& __p, error_code& __ec) noexcept;
00290 
00291   file_status status(const path& __p);
00292   file_status status(const path& __p, error_code& __ec) noexcept;
00293 
00294   inline bool status_known(file_status __s) noexcept
00295   { return __s.type() != file_type::none; }
00296 
00297   file_status symlink_status(const path& __p);
00298   file_status symlink_status(const path& __p, error_code& __ec) noexcept;
00299 
00300   path temp_directory_path();
00301   path temp_directory_path(error_code& __ec);
00302 
00303   path weakly_canonical(const path& __p);
00304   path weakly_canonical(const path& __p, error_code& __ec);
00305 
00306   // @} group filesystem
00307 } // namespace filesystem
00308 
00309 _GLIBCXX_END_NAMESPACE_VERSION
00310 } // namespace std
00311 
00312 #endif // C++17
00313 
00314 #endif // _GLIBCXX_FS_OPS_H