libstdc++
fs_ops.h
00001 // Filesystem operational functions -*- C++ -*-
00002 
00003 // Copyright (C) 2014-2017 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_OPS_H
00031 #define _GLIBCXX_EXPERIMENTAL_FS_OPS_H 1
00032 
00033 #if __cplusplus < 201103L
00034 # include <bits/c++0x_warning.h>
00035 #else
00036 
00037 #include <cstdint>
00038 
00039 namespace std _GLIBCXX_VISIBILITY(default)
00040 {
00041 namespace experimental
00042 {
00043 namespace filesystem
00044 {
00045 inline namespace v1
00046 {
00047 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00048 
00049   /**
00050    * @ingroup filesystem
00051    * @{
00052    */
00053 
00054   path absolute(const path& __p, const path& __base = current_path());
00055 
00056   path canonical(const path& __p, const path& __base = current_path());
00057   path canonical(const path& __p, error_code& __ec);
00058   path canonical(const path& __p, const path& __base, error_code& __ec);
00059 
00060   inline void
00061   copy(const path& __from, const path& __to)
00062   { copy(__from, __to, copy_options::none); }
00063 
00064   inline void
00065   copy(const path& __from, const path& __to, error_code& __ec) noexcept
00066   { copy(__from, __to, copy_options::none, __ec); }
00067 
00068   void copy(const path& __from, const path& __to, copy_options __options);
00069   void copy(const path& __from, const path& __to, copy_options __options,
00070             error_code& __ec) noexcept;
00071 
00072   inline bool
00073   copy_file(const path& __from, const path& __to)
00074   { return copy_file(__from, __to, copy_options::none); }
00075 
00076   inline bool
00077   copy_file(const path& __from, const path& __to, error_code& __ec) noexcept
00078   { return copy_file(__from, __to, copy_options::none, __ec); }
00079 
00080   bool copy_file(const path& __from, const path& __to, copy_options __option);
00081   bool copy_file(const path& __from, const path& __to, copy_options __option,
00082                  error_code& __ec) noexcept;
00083 
00084   void copy_symlink(const path& __existing_symlink, const path& __new_symlink);
00085   void copy_symlink(const path& __existing_symlink, const path& __new_symlink,
00086                     error_code& __ec) noexcept;
00087 
00088   bool create_directories(const path& __p);
00089   bool create_directories(const path& __p, error_code& __ec) noexcept;
00090 
00091   bool create_directory(const path& __p);
00092   bool create_directory(const path& __p, error_code& __ec) noexcept;
00093 
00094   bool create_directory(const path& __p, const path& attributes);
00095   bool create_directory(const path& __p, const path& attributes,
00096                         error_code& __ec) noexcept;
00097 
00098   void create_directory_symlink(const path& __to, const path& __new_symlink);
00099   void create_directory_symlink(const path& __to, const path& __new_symlink,
00100                                 error_code& __ec) noexcept;
00101 
00102   void create_hard_link(const path& __to, const path& __new_hard_link);
00103   void create_hard_link(const path& __to, const path& __new_hard_link,
00104                         error_code& __ec) noexcept;
00105 
00106   void create_symlink(const path& __to, const path& __new_symlink);
00107   void create_symlink(const path& __to, const path& __new_symlink,
00108                       error_code& __ec) noexcept;
00109 
00110   path current_path();
00111   path current_path(error_code& __ec);
00112   void current_path(const path& __p);
00113   void current_path(const path& __p, error_code& __ec) noexcept;
00114 
00115   bool
00116   equivalent(const path& __p1, const path& __p2);
00117 
00118   bool
00119   equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept;
00120 
00121   inline bool
00122   exists(file_status __s) noexcept
00123   { return status_known(__s) && __s.type() != file_type::not_found; }
00124 
00125   inline bool
00126   exists(const path& __p)
00127   { return exists(status(__p)); }
00128 
00129   inline bool
00130   exists(const path& __p, error_code& __ec) noexcept
00131   {
00132     auto __s = status(__p, __ec);
00133     if (status_known(__s))
00134       __ec.clear();
00135     return exists(__s);
00136   }
00137 
00138   uintmax_t file_size(const path& __p);
00139   uintmax_t file_size(const path& __p, error_code& __ec) noexcept;
00140 
00141   uintmax_t hard_link_count(const path& __p);
00142   uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept;
00143 
00144   inline bool
00145   is_block_file(file_status __s) noexcept
00146   { return __s.type() == file_type::block; }
00147 
00148   inline bool
00149   is_block_file(const path& __p)
00150   { return is_block_file(status(__p)); }
00151 
00152   inline bool
00153   is_block_file(const path& __p, error_code& __ec) noexcept
00154   { return is_block_file(status(__p, __ec)); }
00155 
00156   inline bool
00157   is_character_file(file_status __s) noexcept
00158   { return __s.type() == file_type::character; }
00159 
00160   inline bool
00161   is_character_file(const path& __p)
00162   { return is_character_file(status(__p)); }
00163 
00164   inline bool
00165   is_character_file(const path& __p, error_code& __ec) noexcept
00166   { return is_character_file(status(__p, __ec)); }
00167 
00168   inline bool
00169   is_directory(file_status __s) noexcept
00170   { return __s.type() == file_type::directory; }
00171 
00172   inline bool
00173   is_directory(const path& __p)
00174   { return is_directory(status(__p)); }
00175 
00176   inline bool
00177   is_directory(const path& __p, error_code& __ec) noexcept
00178   { return is_directory(status(__p, __ec)); }
00179 
00180   bool is_empty(const path& __p);
00181   bool is_empty(const path& __p, error_code& __ec) noexcept;
00182 
00183   inline bool
00184   is_fifo(file_status __s) noexcept
00185   { return __s.type() == file_type::fifo; }
00186 
00187   inline bool
00188   is_fifo(const path& __p)
00189   { return is_fifo(status(__p)); }
00190 
00191   inline bool
00192   is_fifo(const path& __p, error_code& __ec) noexcept
00193   { return is_fifo(status(__p, __ec)); }
00194 
00195   inline bool
00196   is_other(file_status __s) noexcept
00197   {
00198     return exists(__s) && !is_regular_file(__s) && !is_directory(__s)
00199       && !is_symlink(__s);
00200   }
00201 
00202   inline bool
00203   is_other(const path& __p)
00204   { return is_other(status(__p)); }
00205 
00206   inline bool
00207   is_other(const path& __p, error_code& __ec) noexcept
00208   { return is_other(status(__p, __ec)); }
00209 
00210   inline bool
00211   is_regular_file(file_status __s) noexcept
00212   { return __s.type() == file_type::regular; }
00213 
00214   inline bool
00215   is_regular_file(const path& __p)
00216   { return is_regular_file(status(__p)); }
00217 
00218   inline bool
00219   is_regular_file(const path& __p, error_code& __ec) noexcept
00220   { return is_regular_file(status(__p, __ec)); }
00221 
00222   inline bool
00223   is_socket(file_status __s) noexcept
00224   { return __s.type() == file_type::socket; }
00225 
00226   inline bool
00227   is_socket(const path& __p)
00228   { return is_socket(status(__p)); }
00229 
00230   inline bool
00231   is_socket(const path& __p, error_code& __ec) noexcept
00232   { return is_socket(status(__p, __ec)); }
00233 
00234   inline bool
00235   is_symlink(file_status __s) noexcept
00236   { return __s.type() == file_type::symlink; }
00237 
00238   inline bool
00239   is_symlink(const path& __p)
00240   { return is_symlink(symlink_status(__p)); }
00241 
00242   inline bool
00243   is_symlink(const path& __p, error_code& __ec) noexcept
00244   { return is_symlink(symlink_status(__p, __ec)); }
00245 
00246   file_time_type  last_write_time(const path& __p);
00247   file_time_type  last_write_time(const path& __p, error_code& __ec) noexcept;
00248   void last_write_time(const path& __p, file_time_type __new_time);
00249   void last_write_time(const path& __p, file_time_type __new_time,
00250                        error_code& __ec) noexcept;
00251 
00252   void permissions(const path& __p, perms __prms);
00253   void permissions(const path& __p, perms __prms, error_code& __ec) noexcept;
00254 
00255   path read_symlink(const path& __p);
00256   path read_symlink(const path& __p, error_code& __ec);
00257 
00258   bool remove(const path& __p);
00259   bool remove(const path& __p, error_code& __ec) noexcept;
00260 
00261   uintmax_t remove_all(const path& __p);
00262   uintmax_t remove_all(const path& __p, error_code& __ec) noexcept;
00263 
00264   void rename(const path& __from, const path& __to);
00265   void rename(const path& __from, const path& __to, error_code& __ec) noexcept;
00266 
00267   void resize_file(const path& __p, uintmax_t __size);
00268   void resize_file(const path& __p, uintmax_t __size, error_code& __ec) noexcept;
00269 
00270   space_info space(const path& __p);
00271   space_info space(const path& __p, error_code& __ec) noexcept;
00272 
00273   file_status status(const path& __p);
00274   file_status status(const path& __p, error_code& __ec) noexcept;
00275 
00276   inline bool status_known(file_status __s) noexcept
00277   { return __s.type() != file_type::none; }
00278 
00279   file_status symlink_status(const path& __p);
00280   file_status symlink_status(const path& __p, error_code& __ec) noexcept;
00281 
00282   path system_complete(const path& __p);
00283   path system_complete(const path& __p, error_code& __ec);
00284 
00285   path temp_directory_path();
00286   path temp_directory_path(error_code& __ec);
00287 
00288   // @} group filesystem
00289 _GLIBCXX_END_NAMESPACE_VERSION
00290 } // namespace v1
00291 } // namespace filesystem
00292 } // namespace experimental
00293 } // namespace std
00294 
00295 #endif // C++11
00296 
00297 #endif // _GLIBCXX_EXPERIMENTAL_FS_OPS_H