#define VER_LAMEXP_MINOR_LO 8
#define VER_LAMEXP_TYPE Beta
#define VER_LAMEXP_PATCH 7
-#define VER_LAMEXP_BUILD 2234
+#define VER_LAMEXP_BUILD 2235
#define VER_LAMEXP_CONFG 2188
///////////////////////////////////////////////////////////////////////////////
} \
while(0)
-#define DIR_EXISTS(PATH) (QFileInfo(PATH).exists() && QFileInfo(PATH).isDir())
+////////////////////////////////////////////////////////////
+// Utility functions
+////////////////////////////////////////////////////////////
+
+static bool dir_exists(const QString &path)
+{
+ const QFileInfo info(path);
+ return info.exists() && info.isDir();
+}
+
+static QString find_existing_ancestor(const QString &path)
+{
+ for (QString parentPath = path; !parentPath.isEmpty(); parentPath = MUtils::parent_path(parentPath))
+ {
+ if (dir_exists(parentPath))
+ {
+ return parentPath; /*existing parent found*/
+ }
+ }
+ return QString();
+}
////////////////////////////////////////////////////////////
// Constants
}
}
- if(this->outputDir().isEmpty() || (!DIR_EXISTS(this->outputDir())))
+ if(this->outputDir().isEmpty() || (!dir_exists(this->outputDir())))
{
- qWarning("Output directory not set yet or does NOT exist anymore -> Resetting");
- this->outputDir(defaultDirectory());
+ qWarning("Output directory not set yet or does NOT exist anymore -> resetting!");
+ const QString outputDir = find_existing_ancestor(this->outputDir());
+ this->outputDir((!outputDir.isEmpty()) ? outputDir : defaultDirectory());
}
- if(this->mostRecentInputPath().isEmpty() || (!DIR_EXISTS(this->mostRecentInputPath())))
+ if(this->mostRecentInputPath().isEmpty() || (!dir_exists(this->mostRecentInputPath())))
{
- qWarning("Most recent input directory not set yet or does NOT exist anymore -> Resetting");
- this->mostRecentInputPath(defaultDirectory());
+ qWarning("Most recent input directory not set yet or does NOT exist anymore -> resetting!");
+ const QString inputPath = find_existing_ancestor(this->mostRecentInputPath());
+ this->mostRecentInputPath((!inputPath.isEmpty()) ? inputPath : defaultDirectory());
}
if(!this->currentLanguageFile().isEmpty())