Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
filesystem.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
2 
12 /* This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or (at your option) any later version.
16  *
17  * This software is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public
23  * License along with this software. If not, see
24  * <http://www.gnu.org/licenses/>.
25  *
26  */
27 
28 #ifndef _HUGIN_UTILS_FILESYSTEM_H
29 #define _HUGIN_UTILS_FILESYSTEM_H
30 #include "hugin_config.h"
31 #ifdef HAVE_STD_FILESYSTEM
32  #if defined _MSC_VER && _MSC_VER >= 1920
33  #define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
34  #include <experimental/filesystem>
35  #else
36  #include <filesystem>
37  #endif
38  #if defined _MSC_VER && _MSC_VER <= 1900
39  // MSVC 2015 has implemented in std::tr2::sys
40  namespace fs = std::tr2::sys;
41  #define OVERWRITE_EXISTING std::tr2::sys::copy_options::overwrite_existing
42  #else
43  // MSVC 2017 is using experimental namespace
44  namespace fs = std::experimental::filesystem;
45  #define OVERWRITE_EXISTING std::experimental::filesystem::copy_options::overwrite_existing
46  #endif
47 #else
48  // use Boost::Filesystem as fallback
49  #define BOOST_FILESYSTEM_VERSION 3
50  #ifdef __GNUC__
51  #include <boost/version.hpp>
52  #if BOOST_VERSION<105700
53  #if BOOST_VERSION>=105100
54  // workaround a bug in boost filesystem
55  // boost filesystem is probably compiled with C++03
56  // but Hugin is compiled with C++11, this results in
57  // conflicts in boost::filesystems at a enum
58  // see https://svn.boost.org/trac/boost/ticket/6779
59  #define BOOST_NO_CXX11_SCOPED_ENUMS
60  #else
61  #define BOOST_NO_SCOPED_ENUMS
62  #endif
63  #endif
64  #endif
65  #include <boost/filesystem.hpp>
66  namespace fs = boost::filesystem;
67  #if BOOST_VERSION>=107400
68  // in Boost 1.74 and later filesystem::copy_option is deprecated
69  // use filesystem::copy_options instead
70  #define OVERWRITE_EXISTING boost::filesystem::copy_options::overwrite_existing
71  #else
72  #define OVERWRITE_EXISTING boost::filesystem::copy_option::overwrite_if_exists
73  #endif
74 #endif
75 #endif // _HUGIN_UTILS_FILESYSTEM_H