Skip to content
Snippets Groups Projects
Commit 5008cbd8 authored by Jason Hiser's avatar Jason Hiser :tractor:
Browse files

create install directory if not already exists

parent d4f06f29
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,33 @@
using namespace std;
int mkpath(const string& path, const mode_t& mode)
{
auto s=path;
auto pos=(size_t)0;
if(s[s.size()-1]!='/')
{
// force trailing / so we can handle everything in loop
s+='/';
}
// Caution! side effect in the while loop!
while((pos=s.find_first_of('/',pos))!=string::npos)
{
auto dir=s.substr(0,pos++);
if(dir.size()==0)
continue; // if leading / first time is 0 length
auto mdret=mkdir(dir.c_str(),mode);
if(mdret!=0 && errno!=EEXIST)
{
return mdret;
}
}
return 0;
}
// Parse some options for the transform
static struct option long_options[] = {
{"setup", no_argument, 0, 's'},
......@@ -516,21 +543,6 @@ void read_configs()
auto orig_configfile=trimmed(mf)+".config";
read_config(orig_configfile, my_options.install_dir, my_options.labels);
#if 0
for(const auto & s : manifest_files)
{
string install_dir, labels;
auto configfile=trimmed(s)+".config";
read_config(configfile, install_dir, labels);
if(my_options.install_dir != install_dir || my_options.labels != labels)
{
cerr<<"Mismatch configuration in "<<orig_configfile<<" and "<<configfile<<endl;
exit(1);
}
}
#endif
}
auto previously_had_pedi_root=false;
......@@ -640,6 +652,12 @@ void finish()
{
if(!configs_read || previously_had_pedi_root)
{
auto mkpath_err=mkpath(my_options.install_dir, S_IRUSR | S_IWUSR | S_IXUSR);
if(mkpath_err != 0 )
{
cout << " Could not make directory " << my_options.install_dir << endl;
exit(1);
}
ofstream o(my_options.install_dir+"/"+".pedi_root");
if(my_options.verbose)
cout<<"Writing pedi_root file."<<endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment