Преглед изворни кода

Check default configuration locations before prompting.

Neal Wilson пре 7 година
родитељ
комит
f7e4208c45
1 измењених фајлова са 15 додато и 0 уклоњено
  1. 15
    0
      src/typica.w

+ 15
- 0
src/typica.w Прегледај датотеку

@@ -4377,6 +4377,9 @@ Starting with version 1.4, we check for a command line option with the path to
4377 4377
 the configuration file and load that instead of prompting for the information
4378 4378
 if possible.
4379 4379
 
4380
+Starting with version 1.8, if there is not a -c argument, Typica will first
4381
+search a small number of locations relative to the executable.
4382
+
4380 4383
 @<Load the application configuration@>=
4381 4384
 QStringList arguments = QCoreApplication::arguments();
4382 4385
 int position = arguments.indexOf("-c");
@@ -4387,6 +4390,16 @@ if(position != -1)
4387 4390
     {
4388 4391
         filename = arguments.at(position + 1);
4389 4392
     }
4393
+} else {
4394
+	QDir checkPath(QCoreApplication::applicationDirPath() + "/../config/");
4395
+	if(checkPath.exists("config.xml")) {
4396
+		filename = checkPath.filePath("config.xml");
4397
+	} else {
4398
+		checkPath = QDir(QCoreApplication::applicationDirPath() + "/config/");
4399
+		if(checkPath.exists("config.xml")) {
4400
+			filename  = checkPath.filePath("config.xml");
4401
+		}
4402
+	}
4390 4403
 }
4391 4404
 if(filename.isEmpty())
4392 4405
 {
@@ -4411,6 +4424,8 @@ if(!filename.isEmpty())
4411 4424
     {
4412 4425
         app.configuration()->setContent(&file, true);
4413 4426
     }
4427
+} else {
4428
+	return 1;
4414 4429
 }
4415 4430
 @<Substitute included fragments@>@;
4416 4431
 

Loading…
Откажи
Сачувај