Browse Source

fix using mkdir with boost

unknown 12 years ago
parent
commit
b90d685200
2 changed files with 31 additions and 0 deletions
  1. 16 0
      cbaselib/MultiDataset.cpp
  2. 15 0
      cbaselib/progs/createNormTrainingSet.cpp

+ 16 - 0
cbaselib/MultiDataset.cpp

@@ -10,6 +10,13 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
+#ifdef WIN32
+#ifdef NICE_USELIB_BOOST
+	#include "boost/filesystem.hpp"
+#endif
+#endif
+
+
 #include "vislearning/cbaselib/ClassNames.h"
 
 #include "core/basics/StringTools.h"
@@ -290,7 +297,16 @@ MultiDataset::MultiDataset( const Config *conf , LabeledSetFactory *pSetFactory)
       const LabeledSet & ls = i->second;
       const ClassNames & classNames = classnames[name];
 
+#ifdef WIN32
+#ifdef NICE_USELIB_BOOST
+		boost::filesystem::path t_path(name.c_str());
+		boost::filesystem::create_directory(t_path);
+#else
+		  throw std::exception("mkdir function not defined on system. try using boost lib and rebuild library");
+#endif
+#else
       mkdir ( name.c_str(), 0755 );
+#endif
 
       std::string filelist = name + "/files.txt";
       ofstream olist ( filelist.c_str(), ios::out );

+ 15 - 0
cbaselib/progs/createNormTrainingSet.cpp

@@ -5,6 +5,12 @@
 * @date 07/21/2008
 
 */
+#ifdef WIN32
+#ifdef NICE_USELIB_BOOST
+	#include "boost/filesystem.hpp"
+#endif
+#endif
+
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"
 #include "core/image/ImageT.h"
@@ -208,7 +214,16 @@ int main (int argc, char **argv)
 	// old: string dir = classNames.text(c);
 	std::string dir = classNames.text(c);
 
+#ifdef WIN32
+#ifdef NICE_USELIB_BOOST
+	boost::filesystem::path t_path(dir.c_str());
+	int retcode = boost::filesystem::create_directory(t_path);
+#else
+		  throw std::exception("mkdir function not defined on system. try using boost lib and rebuild library");
+#endif
+#else
 	int retcode = mkdir ( dir.c_str(), 0700 );
+#endif
 	if ( (retcode < 0) && (retcode != EEXIST ) ) {
 	    fprintf (stderr, "Failed to create directory: %s\n", dir.c_str() );
 	    exit(-1);