|
@@ -1,30 +1,33 @@
|
|
|
#include "src/classes/astandardpaths.h"
|
|
|
|
|
|
-QMap<AStandardPaths::Dirs, QString> AStandardPaths::dirs;
|
|
|
+QMap<AStandardPaths::Directories, QString> AStandardPaths::directories;
|
|
|
|
|
|
void AStandardPaths::setup()
|
|
|
{
|
|
|
auto data_location = QStandardPaths::AppDataLocation;
|
|
|
- dirs = { // [G]: potential rename to `dirs`
|
|
|
- {Database, QStandardPaths::writableLocation(data_location)},
|
|
|
- {Templates, QDir(QStandardPaths::writableLocation(data_location)).filePath("templates")},
|
|
|
- {DatabaseBackup, QDir(QStandardPaths::writableLocation(data_location)).filePath("backup")}
|
|
|
+ directories = { // [F]: Dir could be ambiguous since it is very similar to QDir
|
|
|
+ {Database, QDir::toNativeSeparators(
|
|
|
+ QStandardPaths::writableLocation(data_location) + '/')},
|
|
|
+ {Templates, QDir::toNativeSeparators(
|
|
|
+ QDir(QStandardPaths::writableLocation(data_location)).filePath(QStringLiteral("templates/")))},
|
|
|
+ {DatabaseBackup, QDir::toNativeSeparators(
|
|
|
+ QDir(QStandardPaths::writableLocation(data_location)).filePath(QStringLiteral("backup/")))}
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-const QString& AStandardPaths::absPathOf(Dirs loc)
|
|
|
+const QString& AStandardPaths::absPathOf(Directories loc)
|
|
|
{
|
|
|
- return dirs[loc];
|
|
|
+ return directories[loc];
|
|
|
}
|
|
|
|
|
|
-const QMap<AStandardPaths::Dirs, QString>& AStandardPaths::allPaths()
|
|
|
+const QMap<AStandardPaths::Directories, QString>& AStandardPaths::allPaths()
|
|
|
{
|
|
|
- return dirs;
|
|
|
+ return directories;
|
|
|
}
|
|
|
|
|
|
void AStandardPaths::scan_dirs()
|
|
|
{
|
|
|
- for(auto& dir : dirs){
|
|
|
+ for(auto& dir : directories){
|
|
|
auto d = QDir(dir);
|
|
|
if(!d.exists()) {
|
|
|
d.mkpath(dir);
|
|
@@ -32,9 +35,14 @@ void AStandardPaths::scan_dirs()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// [F]: We could make scan_dirs return bool and return false if !exists && !mkpath
|
|
|
+// This function seems like it would do the same as scan_dirs
|
|
|
+// Validating the contents would be rather complex to accomplish and difficult to
|
|
|
+// maintain I believe, since the contents of these directories might change and it
|
|
|
+// seems out of the scope of this class to verify the directories' contents.
|
|
|
bool AStandardPaths::validate_dirs()
|
|
|
{
|
|
|
- for(auto& dir : dirs){
|
|
|
+ for(auto& dir : directories){
|
|
|
//DEB << "Validating " << dir;
|
|
|
if(false) // determine path as valid (scan contents and parse for correctness)
|
|
|
return false;
|