Skip to content

Commit fbfc2c3

Browse files
committed
fix: Windows path for database and default location when not specifying a path
1 parent adf3e38 commit fbfc2c3

1 file changed

Lines changed: 4 additions & 19 deletions

File tree

ozwadmin-main/main.cpp

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ int main(int argc, char *argv[])
126126
}
127127
/* if we dont have a dbPath, Deploy our config files there */
128128
if (dbPath.isEmpty()) {
129-
#ifndef Q_OS_WIN
129+
#if 1
130130
qCWarning(ozwadmin) << "Configuration Database Does Not Exist - Copying Database to Location " << QFileInfo(parser.value(configDir).append("/")).absoluteFilePath();
131131
QStringList Locations;
132132
Locations << ".";
@@ -159,8 +159,7 @@ int main(int argc, char *argv[])
159159
}
160160
/* if we dont have a dbPath, Deploy our config files there */
161161
if (dbPath.isEmpty()) {
162-
#ifndef Q_OS_WIN
163-
dbPath = QFileInfo("./").absoluteFilePath();
162+
dbPath = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).at(0);
164163
qCWarning(ozwadmin) << "Configuration Database Does Not Exist - Copying Database to Default Location " << dbPath;
165164
QStringList Locations;
166165
Locations << ".";
@@ -170,10 +169,6 @@ int main(int argc, char *argv[])
170169
qCWarning(ozwadmin) << "Cant find qt-openzwavedatabase.rcc";
171170
QCoreApplication::exit(-1);
172171
}
173-
#else
174-
qCWarning(ozwadmin) << "Configuration Database Not Found";
175-
QCoreApplication::exit(-1);
176-
#endif
177172
}
178173
}
179174
settings.setValue("openzwave/ConfigPath", dbPath);
@@ -191,7 +186,6 @@ int main(int argc, char *argv[])
191186
}
192187
/* if we dont have a userPath, Deploy our config files there */
193188
if (userPath.isEmpty()) {
194-
#ifndef Q_OS_WIN
195189
qCWarning(ozwadmin) << "User Configuration Path Does Not Exist - Copying Config Files to Location " << QFileInfo(parser.value(userDir).append("/")).absoluteFilePath();
196190
QStringList Locations;
197191
Locations << ".";
@@ -202,10 +196,6 @@ int main(int argc, char *argv[])
202196
QCoreApplication::exit(-1);
203197
}
204198
userPath = QFileInfo(parser.value(userDir).append("/")).absoluteFilePath();
205-
#else
206-
qCWarning(ozwadmin) << "Configuration Database Not Found";
207-
QCoreApplication::exit(-1);
208-
#endif
209199
}
210200
} else {
211201
/* search Default Locations for Config Files */
@@ -224,9 +214,8 @@ int main(int argc, char *argv[])
224214
}
225215
/* if we dont have a dbPath, Deploy our config files there */
226216
if (userPath.isEmpty()) {
227-
#ifndef Q_OS_WIN
228-
userPath = QFileInfo("./").absoluteFilePath();
229-
qCWarning(ozwadmin) << "Configuration Database Does Not Exist - Copying Database to Default Location " << dbPath;
217+
userPath = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).at(0);
218+
qCWarning(ozwadmin) << "Configuration Database Does Not Exist - Copying Database to Default Location " << userPath;
230219
QStringList Locations;
231220
Locations << ".";
232221
if (initConfigDatabase(Locations)) {
@@ -235,10 +224,6 @@ int main(int argc, char *argv[])
235224
qCWarning(ozwadmin) << "Cant find qt-openzwavedatabase.rcc";
236225
QCoreApplication::exit(-1);
237226
}
238-
#else
239-
qCWarning(ozwadmin) << "Configuration Database Not Found";
240-
QCoreApplication::exit(-1);
241-
#endif
242227
}
243228
}
244229
settings.setValue("openzwave/UserPath", userPath);

0 commit comments

Comments
 (0)