summaryrefslogtreecommitdiff
path: root/src/boosty.h
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2013-03-17 17:34:47 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2013-03-17 17:34:47 (GMT)
commit100b1733df981aa542675d2dad198a259a61ccd2 (patch)
tree6b93a88cf634fa2d1b7abbf9cea7511593718f39 /src/boosty.h
parentc855e4d0436a01792b540c7857e1a1997f4810d7 (diff)
backport boost functions to pre-1.48
Diffstat (limited to 'src/boosty.h')
-rw-r--r--src/boosty.h62
1 files changed, 59 insertions, 3 deletions
diff --git a/src/boosty.h b/src/boosty.h
index 6ec417a..5c82002 100644
--- a/src/boosty.h
+++ b/src/boosty.h
@@ -10,9 +10,8 @@
versions of boost found on popular versions of linux, circa early 2012.
design
- hope that the user is compiling with boost>1.46 + filesystem v3
- if not, fall back to older deprecated functions, and rely on
- testing to find bugs. implement the minimum needed by OpenSCAD and no more.
+ the boost filsystem changed around 1.46-1.48. we do a large #ifdef
+ based on boost version that wraps various functions appropriately.
in a few years, this file should be deleted as unnecessary.
see also
@@ -28,6 +27,7 @@
#include <boost/version.hpp>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
+#include "printutils.h"
namespace boosty {
@@ -77,6 +77,62 @@ inline std::string extension_str( fs::path p)
#endif
+
+
+
+
+#if BOOST_VERSION >= 104800
+
+inline fs::path canonical( fs::path p, fs::path p2 )
+{
+ return fs::canonical( p, p2, NULL );
+}
+
+inline fs::path canonical( fs::path p )
+{
+ return fs::canonical( p, fs::current_path(), NULL );
+}
+
+#else
+
+inline fs::path canonical( fs::path p, fs::path p2 )
+{
+ // dotpath: win32/mac builds will be using newer versions of boost
+ // so we can treat this as though it is unix only
+ const fs::path dot_path(".");
+ const fs::path dot_dot_path("..");
+ fs::path result;
+ if (p=="")
+ {
+ p=p2;
+ }
+ for (fs::path::iterator itr = p.begin(); itr != p.end(); itr++)
+ {
+ if (*itr == dot_path) continue;
+ if (*itr == dot_dot_path)
+ {
+ result.remove_filename();
+ continue;
+ }
+ result /= *itr;
+ if (fs::is_symlink(result))
+ {
+ PRINT("WARNING: canonical() wrapper can't do symlinks. upgrade boost to >1.48");
+ }
+ }
+ return result;
+}
+
+inline fs::path canonical( fs::path p )
+{
+ return canonical( p, fs::current_path() );
+}
+
+#endif
+
+
+
+
} // namespace
#endif
contact: Jan Huwald // Impressum