46 #ifndef OME_COMMON_FILESYSTEM_H 47 # define OME_COMMON_FILESYSTEM_H 49 # include <ome/common/config.h> 51 #include <boost/filesystem/operations.hpp> 52 #include <boost/filesystem/path.hpp> 56 # ifdef OME_HAVE_BOOST_FILESYSTEM_CANONICAL 57 # ifdef BOOST_SYSTEM_NO_DEPRECATED 58 # undef BOOST_SYSTEM_NO_DEPRECATED 59 # endif // BOOST_SYSTEM_NO_DEPRECATED 60 # include <boost/system/error_code.hpp> 61 # endif // OME_HAVE_BOOST_FILESYSTEM_CANONICAL 73 # ifdef OME_HAVE_BOOST_FILESYSTEM_ABSOLUTE 75 # else // OME_HAVE_BOOST_FILESYSTEM_ABSOLUTE not defined 84 boost::filesystem::path
86 const boost::filesystem::path& base = boost::filesystem::current_path())
88 return boost::filesystem::complete(p, base);
90 # endif // OME_HAVE_BOOST_FILESYSTEM_ABSOLUTE 93 # ifdef OME_HAVE_BOOST_FILESYSTEM_CANONICAL 95 # else // OME_HAVE_BOOST_FILESYSTEM_CANONICAL not defined 106 boost::filesystem::path
108 const boost::filesystem::path& base = boost::filesystem::current_path(),
109 boost::system::error_code* ec = 0)
111 boost::filesystem::path source (
absolute(p, base));
112 boost::filesystem::path result;
114 boost::system::error_code local_ec;
115 boost::filesystem::file_status stat (status(source, local_ec));
117 if (stat.type() == boost::filesystem::file_not_found)
120 throw boost::filesystem::filesystem_error
121 (
"boost::filesystem::canonical", source,
122 boost::system::error_code(boost::system::errc::no_such_file_or_directory,
123 boost::system::get_generic_category()));
124 ec->assign(boost::system::errc::no_such_file_or_directory,
125 boost::system::get_generic_category());
131 throw(boost::filesystem::filesystem_error
132 (
"boost::filesystem::canonical", source, local_ec));
137 # endif // OME_HAVE_BOOST_FILESYSTEM_CANONICAL 147 boost::filesystem::path
149 boost::filesystem::path to)
153 boost::filesystem::path ret;
154 boost::filesystem::path::const_iterator itrFrom(from.begin());
155 boost::filesystem::path::const_iterator itrTo(to.begin());
158 for(boost::filesystem::path::const_iterator toEnd(to.end()), fromEnd(from.end());
159 itrFrom != fromEnd && itrTo != toEnd && *itrFrom == *itrTo;
163 for(boost::filesystem::path::const_iterator fromEnd(from.end());
167 if((*itrFrom) !=
".")
171 for (boost::filesystem::path::iterator begin = itrTo;
182 #endif // OME_COMMON_FILESYSTEM_H boost::filesystem::path canonical(const boost::filesystem::path &p, const boost::filesystem::path &base=boost::filesystem::current_path(), boost::system::error_code *ec=0)
Get a canonical path.
Definition: filesystem.h:107
boost::filesystem::path make_relative(boost::filesystem::path from, boost::filesystem::path to)
Make a relative path.
Definition: filesystem.h:148
Open Microscopy Environment C++.
Definition: base64.h:48
boost::filesystem::path absolute(const boost::filesystem::path &p, const boost::filesystem::path &base=boost::filesystem::current_path())
Get an absolute path.
Definition: filesystem.h:85