Created
January 6, 2019 17:29
-
-
Save hxhb/a87f928eae22c826108e0b7d3edf4687 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void create_recursion_dir(const string& basepath,const string& rela_path) | |
{ | |
// cout<<path<<endl; | |
std::string recursion_path=basepath; | |
std::string::size_type begin_index=0; | |
std::string::size_type pos_index=rela_path.find("\\",begin_index); | |
if(rela_path.find(":")!=std::string::npos){ | |
std::string::size_type tempcolon = rela_path.find(":"); | |
begin_index=tempcolon+1; | |
pos_index = rela_path.find("\\",begin_index); | |
} | |
while(pos_index!=std::string::npos) | |
{ | |
if(!recursion_path.empty()) | |
recursion_path+="\\"; | |
recursion_path+=std::string(rela_path,begin_index,pos_index-begin_index); | |
// cout<<"begin_index "<<begin_index<<"\t"<<"pos_index "<<pos_index<<" recursion_path is "<<recursion_path<<endl; | |
if(!mkdir(recursion_path.c_str())) | |
cout<<"create "<<recursion_path<<endl; | |
begin_index = pos_index+1; | |
pos_index = rela_path.find("\\",begin_index); | |
} | |
if(begin_index < rela_path.size()-1) | |
{ | |
recursion_path+="\\"+std::string(rela_path,begin_index,rela_path.size()-1); | |
// cout<<"begin_index "<<begin_index<<"\t"<<"pos_index "<<rela_path.size()<<" recursion_path is "<<recursion_path<<endl; | |
if(!mkdir(recursion_path.c_str())) | |
cout<<"create "<<recursion_path<<endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment