فهرست منبع

fixed using boost for mkdir (cross platform)

unknown 12 سال پیش
والد
کامیت
f39d67f27a
1فایلهای تغییر یافته به همراه21 افزوده شده و 2 حذف شده
  1. 21 2
      baselib/Globals.cpp

+ 21 - 2
baselib/Globals.cpp

@@ -7,7 +7,13 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
+#ifdef WIN32
+#ifdef NICE_USELIB_BOOST
+	#include "boost/filesystem.hpp"
+#endif
+#else
+	#include <unistd.h>
+#endif
 
 using namespace OBJREC;
 using namespace NICE;
@@ -69,11 +75,24 @@ std::string Globals::getCacheFilename ( const std::string & root, int cache_mode
       struct stat info;
 
       if ( stat (dir.c_str(), &info ) < 0 ) {
-        if ( mkdir(dir.c_str(), 0755) < 0 )
+#ifdef WIN32
+#ifdef NICE_USELIB_BOOST
+		  boost::filesystem::path t_path(dir.c_str());
+		  if ( boost::filesystem::create_directory(t_path) < 0 )
         {
           cerr << "Globals::getCacheFilename: unable to create directory: " << dir << endl;
           exit(-1);
         }
+#else
+		  throw std::exception("mkdir function not defined on system. try using boost lib and rebuild library");
+#endif
+#else
+		  if ( mkdir(dir.c_str(), 0755) < 0 )
+        {
+          cerr << "Globals::getCacheFilename: unable to create directory: " << dir << endl;
+          exit(-1);
+        }
+#endif
       }
       
       std::string id = dir + FILESEPSTRING + name;