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 72 # ifdef OME_HAVE_BOOST_FILESYSTEM_ABSOLUTE 74 # else // OME_HAVE_BOOST_FILESYSTEM_ABSOLUTE not defined 83 boost::filesystem::path
85 const boost::filesystem::path& base = boost::filesystem::current_path())
87 return boost::filesystem::complete(p, base);
89 # endif // OME_HAVE_BOOST_FILESYSTEM_ABSOLUTE 91 # ifdef OME_HAVE_BOOST_FILESYSTEM_CANONICAL 93 # else // OME_HAVE_BOOST_FILESYSTEM_CANONICAL not defined 104 boost::filesystem::path
106 const boost::filesystem::path& base = boost::filesystem::current_path(),
107 boost::system::error_code* ec = 0)
109 boost::filesystem::path source (
absolute(p, base));
110 boost::filesystem::path result;
112 boost::system::error_code local_ec;
113 boost::filesystem::file_status stat (status(source, local_ec));
115 if (stat.type() == boost::filesystem::file_not_found)
118 throw boost::filesystem::filesystem_error
119 (
"boost::filesystem::canonical", source,
120 boost::system::error_code(boost::system::errc::no_such_file_or_directory,
121 boost::system::get_generic_category()));
122 ec->assign(boost::system::errc::no_such_file_or_directory,
123 boost::system::get_generic_category());
129 throw(boost::filesystem::filesystem_error
130 (
"boost::filesystem::canonical", source, local_ec));
135 # endif // OME_HAVE_BOOST_FILESYSTEM_CANONICAL 145 boost::filesystem::path
147 boost::filesystem::path to)
151 boost::filesystem::path ret;
152 boost::filesystem::path::const_iterator itrFrom(from.begin());
153 boost::filesystem::path::const_iterator itrTo(to.begin());
156 for(boost::filesystem::path::const_iterator toEnd(to.end()), fromEnd(from.end());
157 itrFrom != fromEnd && itrTo != toEnd && *itrFrom == *itrTo;
161 for(boost::filesystem::path::const_iterator fromEnd(from.end());
165 if((*itrFrom) !=
".")
169 for (boost::filesystem::path::iterator begin = itrTo;
180 #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:105
boost::filesystem::path make_relative(boost::filesystem::path from, boost::filesystem::path to)
Make a relative path.
Definition: filesystem.h:146
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:84