File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 66#include < QTranslator>
77#include < QFileInfo>
88
9+ #include " log.h"
910#include " settings.h"
1011
1112extern " C" {
@@ -44,13 +45,21 @@ static void initLocale(QTranslator *qtTranslator, QTranslator *translator)
4445 app->installTranslator (translator);
4546}
4647
47- void initConfig (std::string &config_file )
48+ void initConfig (std::string &configFile )
4849{
49- bool success = xml_init (config_file.data ());
50+ // mkdir -p
51+ if (!std::filesystem::exists (configFile)) {
52+ size_t filenamePosition = configFile.find_last_of (" /" );
53+ std::string dirname = configFile.substr (0 , filenamePosition);
54+ info (" Creating directory '{}'" , dirname);
55+ std::filesystem::create_directories (dirname);
56+ }
57+
58+ bool success = xml_init (configFile.data ());
5059
5160 if (!success) {
5261 QMessageBox msgBox;
53- msgBox.setText (QObject::tr (" Error loading " ) + QString (config_file .data ()));
62+ msgBox.setText (QObject::tr (" Error loading " ) + QString (configFile .data ()));
5463 msgBox.setInformativeText (
5564 QObject::tr (" Run labwc-tweaks from a terminal to view error messages" ));
5665 msgBox.exec ();
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ create_basic_rcxml(const char *filename)
133133{
134134 FILE * file = fopen (filename , "w" );
135135 if (!file ) {
136- fprintf (stderr , "warn: fopen(%s) failed \n" , filename );
136+ fprintf (stderr , "warn: cannot create file '%s' \n" , filename );
137137 return ;
138138 }
139139 if (!fwrite (rcxml_template , sizeof (rcxml_template )- 1 , 1 , file )) {
You can’t perform that action at this time.
0 commit comments