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