commit 44018f5c90ce4e0f815d77a98c76ac4245287b6b parent 062074e58165845be38232b119a06c77994d329a Author: Michael Savage <mikejsavage@gmail.com> Date: Fri Jun 2 02:02:02 +0300 Use patterns in recursive_mkdir Diffstat:
launcher/main.cc | | | 18 | ++++++------------ |
diff --git a/launcher/main.cc b/launcher/main.cc @@ -181,19 +181,13 @@ static void recursive_mkdir( std::vector< std::string > * directories_to_remove, const std::string & path ) { - size_t start = 0; - while( true ) { - size_t end = path.find( "/", start ); - if( end == std::string::npos ) { - return; - } - - const std::string subdir = path.substr( 0, end ); - mkdir( subdir.c_str(), 0755 ); - start = end + 1; - + std::string cur; + for( array< array< const char > > matches : gmatch( path.c_str(), "([^/]+)/" ) ) { + cur.append( matches[ 0 ].ptr(), matches[ 0 ].n ); + cur += '/'; + mkdir( cur.c_str(), 0755 ); if( directories_to_remove != NULL ) { - directories_to_remove->push_back( subdir ); + directories_to_remove->push_back( cur ); } } }