Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. // Filesystem declarations -*- C++ -*-
  2.  
  3. // Copyright (C) 2014-2015 Free Software Foundation, Inc.
  4. //
  5. // This file is part of the GNU ISO C++ Library.  This library is free
  6. // software; you can redistribute it and/or modify it under the
  7. // terms of the GNU General Public License as published by the
  8. // Free Software Foundation; either version 3, or (at your option)
  9. // any later version.
  10.  
  11. // This library is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. // GNU General Public License for more details.
  15.  
  16. // Under Section 7 of GPL version 3, you are granted additional
  17. // permissions described in the GCC Runtime Library Exception, version
  18. // 3.1, as published by the Free Software Foundation.
  19.  
  20. // You should have received a copy of the GNU General Public License and
  21. // a copy of the GCC Runtime Library Exception along with this program;
  22. // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
  23. // <http://www.gnu.org/licenses/>.
  24.  
  25. /** @file experimental/fs_fwd.h
  26.  *  This is an internal header file, included by other library headers.
  27.  *  Do not attempt to use it directly. @headername{experimental/filesystem}
  28.  */
  29.  
  30. #ifndef _GLIBCXX_EXPERIMENTAL_FS_FWD_H
  31. #define _GLIBCXX_EXPERIMENTAL_FS_FWD_H 1
  32.  
  33. #if __cplusplus < 201103L
  34. # include <bits/c++0x_warning.h>
  35. #else
  36.  
  37. #include <system_error>
  38. #include <cstdint>
  39. #include <chrono>
  40.  
  41. namespace std _GLIBCXX_VISIBILITY(default)
  42. {
  43. namespace experimental
  44. {
  45. namespace filesystem
  46. {
  47. inline namespace v1
  48. {
  49. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  50.  
  51. #if _GLIBCXX_USE_CXX11_ABI
  52.   inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
  53. #endif
  54.  
  55.   /**
  56.    * @defgroup filesystem Filesystem
  57.    * @ingroup experimental
  58.    *
  59.    * Utilities for performing operations on file systems and their components,
  60.    * such as paths, regular files, and directories.
  61.    *
  62.    * @{
  63.    */
  64.  
  65.   class file_status;
  66. _GLIBCXX_BEGIN_NAMESPACE_CXX11
  67.   class path;
  68.   class filesystem_error;
  69.   class directory_entry;
  70.   class directory_iterator;
  71.   class recursive_directory_iterator;
  72. _GLIBCXX_END_NAMESPACE_CXX11
  73.  
  74.   struct space_info
  75.   {
  76.     uintmax_t capacity;
  77.     uintmax_t free;
  78.     uintmax_t available;
  79.   };
  80.  
  81.   enum class file_type : signed char {
  82.       none = 0, not_found = -1, regular = 1, directory = 2, symlink = 3,
  83.       block = 4, character = 5, fifo = 6, socket = 7, unknown = 8
  84.   };
  85.  
  86.   /// Bitmask type
  87.   enum class copy_options : unsigned short {
  88.       none = 0,
  89.       skip_existing = 1, overwrite_existing = 2, update_existing = 4,
  90.       recursive = 8,
  91.       copy_symlinks = 16, skip_symlinks = 32,
  92.       directories_only = 64, create_symlinks = 128, create_hard_links = 256
  93.   };
  94.  
  95.   constexpr copy_options
  96.   operator&(copy_options __x, copy_options __y) noexcept
  97.   {
  98.     using __utype = typename std::underlying_type<copy_options>::type;
  99.     return static_cast<copy_options>(
  100.         static_cast<__utype>(__x) & static_cast<__utype>(__y));
  101.   }
  102.  
  103.   constexpr copy_options
  104.   operator|(copy_options __x, copy_options __y) noexcept
  105.   {
  106.     using __utype = typename std::underlying_type<copy_options>::type;
  107.     return static_cast<copy_options>(
  108.         static_cast<__utype>(__x) | static_cast<__utype>(__y));
  109.   }
  110.  
  111.   constexpr copy_options
  112.   operator^(copy_options __x, copy_options __y) noexcept
  113.   {
  114.     using __utype = typename std::underlying_type<copy_options>::type;
  115.     return static_cast<copy_options>(
  116.         static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
  117.   }
  118.  
  119.   constexpr copy_options
  120.   operator~(copy_options __x) noexcept
  121.   {
  122.     using __utype = typename std::underlying_type<copy_options>::type;
  123.     return static_cast<copy_options>(~static_cast<__utype>(__x));
  124.   }
  125.  
  126.   inline copy_options&
  127.   operator&=(copy_options& __x, copy_options __y) noexcept
  128.   { return __x = __x & __y; }
  129.  
  130.   inline copy_options&
  131.   operator|=(copy_options& __x, copy_options __y) noexcept
  132.   { return __x = __x | __y; }
  133.  
  134.   inline copy_options&
  135.   operator^=(copy_options& __x, copy_options __y) noexcept
  136.   { return __x = __x ^ __y; }
  137.  
  138.  
  139.   /// Bitmask type
  140.   enum class perms : unsigned {
  141.       none              =  0,
  142.       owner_read        =  0400,
  143.       owner_write       =  0200,
  144.       owner_exec        =  0100,
  145.       owner_all         =  0700,
  146.       group_read        =   040,
  147.       group_write       =   020,
  148.       group_exec        =   010,
  149.       group_all         =   070,
  150.       others_read       =    04,
  151.       others_write      =    02,
  152.       others_exec       =    01,
  153.       others_all        =    07,
  154.       all               =  0777,
  155.       set_uid           = 04000,
  156.       set_gid           = 02000,
  157.       sticky_bit        = 01000,
  158.       mask              = 07777,
  159.       unknown           =  0xFFFF,
  160.       add_perms         = 0x10000,
  161.       remove_perms      = 0x20000,
  162.       resolve_symlinks  = 0x40000
  163.   };
  164.  
  165.   constexpr perms
  166.   operator&(perms __x, perms __y) noexcept
  167.   {
  168.     using __utype = typename std::underlying_type<perms>::type;
  169.     return static_cast<perms>(
  170.         static_cast<__utype>(__x) & static_cast<__utype>(__y));
  171.   }
  172.  
  173.   constexpr perms
  174.   operator|(perms __x, perms __y) noexcept
  175.   {
  176.     using __utype = typename std::underlying_type<perms>::type;
  177.     return static_cast<perms>(
  178.         static_cast<__utype>(__x) | static_cast<__utype>(__y));
  179.   }
  180.  
  181.   constexpr perms
  182.   operator^(perms __x, perms __y) noexcept
  183.   {
  184.     using __utype = typename std::underlying_type<perms>::type;
  185.     return static_cast<perms>(
  186.         static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
  187.   }
  188.  
  189.   constexpr perms
  190.   operator~(perms __x) noexcept
  191.   {
  192.     using __utype = typename std::underlying_type<perms>::type;
  193.     return static_cast<perms>(~static_cast<__utype>(__x));
  194.   }
  195.  
  196.   inline perms&
  197.   operator&=(perms& __x, perms __y) noexcept
  198.   { return __x = __x & __y; }
  199.  
  200.   inline perms&
  201.   operator|=(perms& __x, perms __y) noexcept
  202.   { return __x = __x | __y; }
  203.  
  204.   inline perms&
  205.   operator^=(perms& __x, perms __y) noexcept
  206.   { return __x = __x ^ __y; }
  207.  
  208.   // Bitmask type
  209.   enum class directory_options : unsigned char {
  210.       none = 0, follow_directory_symlink = 1, skip_permission_denied = 2
  211.   };
  212.  
  213.   constexpr directory_options
  214.   operator&(directory_options __x, directory_options __y) noexcept
  215.   {
  216.     using __utype = typename std::underlying_type<directory_options>::type;
  217.     return static_cast<directory_options>(
  218.         static_cast<__utype>(__x) & static_cast<__utype>(__y));
  219.   }
  220.  
  221.   constexpr directory_options
  222.   operator|(directory_options __x, directory_options __y) noexcept
  223.   {
  224.     using __utype = typename std::underlying_type<directory_options>::type;
  225.     return static_cast<directory_options>(
  226.         static_cast<__utype>(__x) | static_cast<__utype>(__y));
  227.   }
  228.  
  229.   constexpr directory_options
  230.   operator^(directory_options __x, directory_options __y) noexcept
  231.   {
  232.     using __utype = typename std::underlying_type<directory_options>::type;
  233.     return static_cast<directory_options>(
  234.         static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
  235.   }
  236.  
  237.   constexpr directory_options
  238.   operator~(directory_options __x) noexcept
  239.   {
  240.     using __utype = typename std::underlying_type<directory_options>::type;
  241.     return static_cast<directory_options>(~static_cast<__utype>(__x));
  242.   }
  243.  
  244.   inline directory_options&
  245.   operator&=(directory_options& __x, directory_options __y) noexcept
  246.   { return __x = __x & __y; }
  247.  
  248.   inline directory_options&
  249.   operator|=(directory_options& __x, directory_options __y) noexcept
  250.   { return __x = __x | __y; }
  251.  
  252.   inline directory_options&
  253.   operator^=(directory_options& __x, directory_options __y) noexcept
  254.   { return __x = __x ^ __y; }
  255.  
  256.   typedef chrono::time_point<chrono::system_clock> file_time_type;
  257.  
  258.   // operational functions
  259.  
  260.   void copy(const path& __from, const path& __to, copy_options __options);
  261.   void copy(const path& __from, const path& __to, copy_options __options,
  262.             error_code&) noexcept;
  263.  
  264.   bool copy_file(const path& __from, const path& __to, copy_options __option);
  265.   bool copy_file(const path& __from, const path& __to, copy_options __option,
  266.                  error_code&) noexcept;
  267.  
  268.   path current_path();
  269.  
  270.   file_status status(const path&);
  271.   file_status status(const path&, error_code&) noexcept;
  272.  
  273.   bool status_known(file_status) noexcept;
  274.  
  275.   file_status symlink_status(const path&);
  276.   file_status symlink_status(const path&, error_code&) noexcept;
  277.  
  278.   bool is_regular_file(file_status) noexcept;
  279.   bool is_symlink(file_status) noexcept;
  280.  
  281.   // @} group filesystem
  282. _GLIBCXX_END_NAMESPACE_VERSION
  283. } // namespace v1
  284. } // namespace filesystem
  285. } // namespace experimental
  286. } // namespace std
  287.  
  288. #endif // C++11
  289.  
  290. #endif // _GLIBCXX_EXPERIMENTAL_FS_FWD_H
  291.