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 6
6
#include < QTranslator>
7
7
#include < QFileInfo>
8
8
9
+ #include " log.h"
9
10
#include " settings.h"
10
11
11
12
extern " C" {
@@ -44,13 +45,21 @@ static void initLocale(QTranslator *qtTranslator, QTranslator *translator)
44
45
app->installTranslator (translator);
45
46
}
46
47
47
- void initConfig (std::string &config_file )
48
+ void initConfig (std::string &configFile )
48
49
{
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 ());
50
59
51
60
if (!success) {
52
61
QMessageBox msgBox;
53
- msgBox.setText (QObject::tr (" Error loading " ) + QString (config_file .data ()));
62
+ msgBox.setText (QObject::tr (" Error loading " ) + QString (configFile .data ()));
54
63
msgBox.setInformativeText (
55
64
QObject::tr (" Run labwc-tweaks from a terminal to view error messages" ));
56
65
msgBox.exec ();
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ create_basic_rcxml(const char *filename)
133
133
{
134
134
FILE * file = fopen (filename , "w" );
135
135
if (!file ) {
136
- fprintf (stderr , "warn: fopen(%s) failed \n" , filename );
136
+ fprintf (stderr , "warn: cannot create file '%s' \n" , filename );
137
137
return ;
138
138
}
139
139
if (!fwrite (rcxml_template , sizeof (rcxml_template )- 1 , 1 , file )) {
You can’t perform that action at this time.
0 commit comments