libstdc++
fs_fwd.h
Go to the documentation of this file.
00001 // Filesystem declarations -*- C++ -*-
00002 
00003 // Copyright (C) 2014-2018 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_FWD_H
00031 #define _GLIBCXX_FS_FWD_H 1
00032 
00033 #if __cplusplus >= 201703L
00034 
00035 #include <system_error>
00036 #include <cstdint>
00037 #include <chrono>
00038 
00039 namespace std _GLIBCXX_VISIBILITY(default)
00040 {
00041 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00042 
00043 namespace filesystem
00044 {
00045 #if _GLIBCXX_USE_CXX11_ABI
00046 inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
00047 #endif
00048 
00049   /**
00050    * @defgroup filesystem Filesystem
00051    *
00052    * Utilities for performing operations on file systems and their components,
00053    * such as paths, regular files, and directories.
00054    *
00055    * @{
00056    */
00057 
00058   class file_status;
00059 _GLIBCXX_BEGIN_NAMESPACE_CXX11
00060   class path;
00061   class filesystem_error;
00062   class directory_entry;
00063   class directory_iterator;
00064   class recursive_directory_iterator;
00065 _GLIBCXX_END_NAMESPACE_CXX11
00066 
00067   struct space_info
00068   {
00069     uintmax_t capacity;
00070     uintmax_t free;
00071     uintmax_t available;
00072   };
00073 
00074   enum class file_type : signed char {
00075       none = 0, not_found = -1, regular = 1, directory = 2, symlink = 3,
00076       block = 4, character = 5, fifo = 6, socket = 7, unknown = 8
00077   };
00078 
00079   /// Bitmask type
00080   enum class copy_options : unsigned short {
00081       none = 0,
00082       skip_existing = 1, overwrite_existing = 2, update_existing = 4,
00083       recursive = 8,
00084       copy_symlinks = 16, skip_symlinks = 32,
00085       directories_only = 64, create_symlinks = 128, create_hard_links = 256
00086   };
00087 
00088   constexpr copy_options
00089   operator&(copy_options __x, copy_options __y) noexcept
00090   {
00091     using __utype = typename std::underlying_type<copy_options>::type;
00092     return static_cast<copy_options>(
00093         static_cast<__utype>(__x) & static_cast<__utype>(__y));
00094   }
00095 
00096   constexpr copy_options
00097   operator|(copy_options __x, copy_options __y) noexcept
00098   {
00099     using __utype = typename std::underlying_type<copy_options>::type;
00100     return static_cast<copy_options>(
00101         static_cast<__utype>(__x) | static_cast<__utype>(__y));
00102   }
00103 
00104   constexpr copy_options
00105   operator^(copy_options __x, copy_options __y) noexcept
00106   {
00107     using __utype = typename std::underlying_type<copy_options>::type;
00108     return static_cast<copy_options>(
00109         static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
00110   }
00111 
00112   constexpr copy_options
00113   operator~(copy_options __x) noexcept
00114   {
00115     using __utype = typename std::underlying_type<copy_options>::type;
00116     return static_cast<copy_options>(~static_cast<__utype>(__x));
00117   }
00118 
00119   inline copy_options&
00120   operator&=(copy_options& __x, copy_options __y) noexcept
00121   { return __x = __x & __y; }
00122 
00123   inline copy_options&
00124   operator|=(copy_options& __x, copy_options __y) noexcept
00125   { return __x = __x | __y; }
00126 
00127   inline copy_options&
00128   operator^=(copy_options& __x, copy_options __y) noexcept
00129   { return __x = __x ^ __y; }
00130 
00131 
00132   /// Bitmask type
00133   enum class perms : unsigned {
00134       none              =  0,
00135       owner_read        =  0400,
00136       owner_write       =  0200,
00137       owner_exec        =  0100,
00138       owner_all         =  0700,
00139       group_read        =   040,
00140       group_write       =   020,
00141       group_exec        =   010,
00142       group_all         =   070,
00143       others_read       =    04,
00144       others_write      =    02,
00145       others_exec       =    01,
00146       others_all        =    07,
00147       all               =  0777,
00148       set_uid           = 04000,
00149       set_gid           = 02000,
00150       sticky_bit        = 01000,
00151       mask              = 07777,
00152       unknown           =  0xFFFF,
00153   };
00154 
00155   constexpr perms
00156   operator&(perms __x, perms __y) noexcept
00157   {
00158     using __utype = typename std::underlying_type<perms>::type;
00159     return static_cast<perms>(
00160         static_cast<__utype>(__x) & static_cast<__utype>(__y));
00161   }
00162 
00163   constexpr perms
00164   operator|(perms __x, perms __y) noexcept
00165   {
00166     using __utype = typename std::underlying_type<perms>::type;
00167     return static_cast<perms>(
00168         static_cast<__utype>(__x) | static_cast<__utype>(__y));
00169   }
00170 
00171   constexpr perms
00172   operator^(perms __x, perms __y) noexcept
00173   {
00174     using __utype = typename std::underlying_type<perms>::type;
00175     return static_cast<perms>(
00176         static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
00177   }
00178 
00179   constexpr perms
00180   operator~(perms __x) noexcept
00181   {
00182     using __utype = typename std::underlying_type<perms>::type;
00183     return static_cast<perms>(~static_cast<__utype>(__x));
00184   }
00185 
00186   inline perms&
00187   operator&=(perms& __x, perms __y) noexcept
00188   { return __x = __x & __y; }
00189 
00190   inline perms&
00191   operator|=(perms& __x, perms __y) noexcept
00192   { return __x = __x | __y; }
00193 
00194   inline perms&
00195   operator^=(perms& __x, perms __y) noexcept
00196   { return __x = __x ^ __y; }
00197 
00198   /// Bitmask type
00199   enum class perm_options : unsigned {
00200       replace   = 0x1,
00201       add       = 0x2,
00202       remove    = 0x4,
00203       nofollow  = 0x8
00204   };
00205 
00206   constexpr perm_options
00207   operator&(perm_options __x, perm_options __y) noexcept
00208   {
00209     using __utype = typename std::underlying_type<perm_options>::type;
00210     return static_cast<perm_options>(
00211         static_cast<__utype>(__x) & static_cast<__utype>(__y));
00212   }
00213 
00214   constexpr perm_options
00215   operator|(perm_options __x, perm_options __y) noexcept
00216   {
00217     using __utype = typename std::underlying_type<perm_options>::type;
00218     return static_cast<perm_options>(
00219         static_cast<__utype>(__x) | static_cast<__utype>(__y));
00220   }
00221 
00222   constexpr perm_options
00223   operator^(perm_options __x, perm_options __y) noexcept
00224   {
00225     using __utype = typename std::underlying_type<perm_options>::type;
00226     return static_cast<perm_options>(
00227         static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
00228   }
00229 
00230   constexpr perm_options
00231   operator~(perm_options __x) noexcept
00232   {
00233     using __utype = typename std::underlying_type<perm_options>::type;
00234     return static_cast<perm_options>(~static_cast<__utype>(__x));
00235   }
00236 
00237   inline perm_options&
00238   operator&=(perm_options& __x, perm_options __y) noexcept
00239   { return __x = __x & __y; }
00240 
00241   inline perm_options&
00242   operator|=(perm_options& __x, perm_options __y) noexcept
00243   { return __x = __x | __y; }
00244 
00245   inline perm_options&
00246   operator^=(perm_options& __x, perm_options __y) noexcept
00247   { return __x = __x ^ __y; }
00248 
00249   // Bitmask type
00250   enum class directory_options : unsigned char {
00251       none = 0, follow_directory_symlink = 1, skip_permission_denied = 2
00252   };
00253 
00254   constexpr directory_options
00255   operator&(directory_options __x, directory_options __y) noexcept
00256   {
00257     using __utype = typename std::underlying_type<directory_options>::type;
00258     return static_cast<directory_options>(
00259         static_cast<__utype>(__x) & static_cast<__utype>(__y));
00260   }
00261 
00262   constexpr directory_options
00263   operator|(directory_options __x, directory_options __y) noexcept
00264   {
00265     using __utype = typename std::underlying_type<directory_options>::type;
00266     return static_cast<directory_options>(
00267         static_cast<__utype>(__x) | static_cast<__utype>(__y));
00268   }
00269 
00270   constexpr directory_options
00271   operator^(directory_options __x, directory_options __y) noexcept
00272   {
00273     using __utype = typename std::underlying_type<directory_options>::type;
00274     return static_cast<directory_options>(
00275         static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
00276   }
00277 
00278   constexpr directory_options
00279   operator~(directory_options __x) noexcept
00280   {
00281     using __utype = typename std::underlying_type<directory_options>::type;
00282     return static_cast<directory_options>(~static_cast<__utype>(__x));
00283   }
00284 
00285   inline directory_options&
00286   operator&=(directory_options& __x, directory_options __y) noexcept
00287   { return __x = __x & __y; }
00288 
00289   inline directory_options&
00290   operator|=(directory_options& __x, directory_options __y) noexcept
00291   { return __x = __x | __y; }
00292 
00293   inline directory_options&
00294   operator^=(directory_options& __x, directory_options __y) noexcept
00295   { return __x = __x ^ __y; }
00296 
00297   using file_time_type = std::chrono::system_clock::time_point;
00298 
00299   // operational functions
00300 
00301   void copy(const path& __from, const path& __to, copy_options __options);
00302   void copy(const path& __from, const path& __to, copy_options __options,
00303             error_code&);
00304 
00305   bool copy_file(const path& __from, const path& __to, copy_options __option);
00306   bool copy_file(const path& __from, const path& __to, copy_options __option,
00307                  error_code&);
00308 
00309   path current_path();
00310 
00311   bool exists(file_status) noexcept;
00312 
00313   bool is_other(file_status) noexcept;
00314 
00315   uintmax_t file_size(const path&);
00316   uintmax_t file_size(const path&, error_code&) noexcept;
00317   uintmax_t hard_link_count(const path&);
00318   uintmax_t hard_link_count(const path&, error_code&) noexcept;
00319   file_time_type last_write_time(const path&);
00320   file_time_type last_write_time(const path&, error_code&) noexcept;
00321 
00322   void permissions(const path&, perms, perm_options, error_code&) noexcept;
00323 
00324   path proximate(const path& __p, const path& __base, error_code& __ec);
00325   path proximate(const path& __p, const path& __base, error_code& __ec);
00326 
00327   path relative(const path& __p, const path& __base, error_code& __ec);
00328 
00329   file_status status(const path&);
00330   file_status status(const path&, error_code&) noexcept;
00331 
00332   bool status_known(file_status) noexcept;
00333 
00334   file_status symlink_status(const path&);
00335   file_status symlink_status(const path&, error_code&) noexcept;
00336 
00337   bool is_regular_file(file_status) noexcept;
00338   bool is_symlink(file_status) noexcept;
00339 
00340   // @} group filesystem
00341 } // namespace filesystem
00342 
00343 _GLIBCXX_END_NAMESPACE_VERSION
00344 } // namespace std
00345 
00346 #endif // C++17
00347 
00348 #endif // _GLIBCXX_FS_FWD_H