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