File tree 1 file changed +18
-14
lines changed
1 file changed +18
-14
lines changed Original file line number Diff line number Diff line change @@ -45,10 +45,6 @@ Date: January 2012
45
45
#include < cstring>
46
46
#endif
47
47
48
- #ifdef USE_BOOST
49
- #include < boost/filesystem.hpp>
50
- #endif
51
-
52
48
#include " file_util.h"
53
49
54
50
@@ -238,18 +234,26 @@ std::string fileutl_remove_extension(std::string const &filename)
238
234
void fileutl_create_directory (std::string const &pathname)
239
235
{
240
236
# if defined(WIN32)
241
- std::system ((std::string (" mkdir \" " ) + pathname + " \" " ).c_str ());
242
- # elif defined(__linux__) || defined(__APPLE__)
243
- #ifdef USE_BOOST
244
- boost::filesystem::create_directories (pathname);
237
+ char path_sep=' \\ ' ;
245
238
#else
246
- auto ignore = std::system (
247
- (std::string (" mkdir -p \" " ) + pathname + " \" " ).c_str ());
248
- (void )ignore;
239
+ char path_sep=' /' ;
249
240
#endif
250
- # else
251
- # error "Unsuported platform."
252
- # endif
241
+ std::size_t search_from=0 ;
242
+ while (search_from!=std::string::npos)
243
+ {
244
+ // Search from after the previous path separator, incidentally
245
+ // skipping trying to create '/' if an absolute path is given
246
+ search_from=pathname.find (path_sep, search_from+1 );
247
+ std::string truncated_pathname=pathname.substr (0 , search_from);
248
+ #if defined(WIN32)
249
+ _mkdir (truncated_pathname.c_str ());
250
+ #else
251
+ mkdir (truncated_pathname.c_str (), 0777 );
252
+ #endif
253
+ // Ignore return-- regardless of why we can't create a
254
+ // path prefix, we might as well keep trying down to more
255
+ // specific paths.
256
+ }
253
257
}
254
258
255
259
std::string fileutl_concatenate_file_paths (
You can’t perform that action at this time.
0 commit comments