1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

feat(paths): add path for log file and tests

This commit is contained in:
sudden6 2018-11-11 00:38:45 +01:00
parent 2ff649e80d
commit 9f59ec2cc2
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
3 changed files with 29 additions and 1 deletions

View File

@ -11,6 +11,7 @@
namespace {
const QLatin1Literal globalSettingsFile{"qtox.ini"};
const QLatin1Literal logFile{"qtox.log"};
const QLatin1Literal profileFolder{"profiles"};
const QLatin1Literal themeFolder{"themes"};
const QLatin1Literal avatarsFolder{"avatars"};
@ -134,6 +135,29 @@ QString Paths::getGlobalSettingsPath() const
return path % QDir::separator() % globalSettingsFile;
}
/**
* @brief Returns the path to the log file "qtox.log"
* @return The path to the folder.
*/
QString Paths::getLogFilePath() const
{
QString path;
if (portable) {
path = basePath;
} else {
path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
if (path.isEmpty()) {
qDebug() << "Can't find writable location for log file";
return {};
}
}
// we assume a writeable path for portable mode
return path % QDir::separator() % logFile;
}
/**
* @brief Get the folder where profile specific information is stored, e.g. <profile>.ini
* @return The path to the folder.

View File

@ -17,6 +17,7 @@ public:
bool isPortable() const;
QString getGlobalSettingsPath() const;
QString getLogFilePath() const;
QString getProfilesDir() const;
QString getToxSaveDir() const;
QString getAvatarsDir() const;

View File

@ -41,6 +41,7 @@ private:
namespace {
const QLatin1Literal globalSettingsFile{"qtox.ini"};
const QLatin1Literal logFile{"qtox.log"};
const QLatin1Literal profileFolder{"profiles"};
const QLatin1Literal themeFolder{"themes"};
const QLatin1Literal avatarsFolder{"avatars"};
@ -112,10 +113,11 @@ void TestPaths::checkPathsNonPortable()
const QString appData{QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)};
const QString appConfig{QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)};
const QString cache{QStandardPaths::writableLocation(QStandardPaths::CacheLocation)};
verifyqToxPath(paths->getProfilesDir(), appData, profileFolder % sep);
verifyqToxPath(paths->getGlobalSettingsPath(), appConfig, globalSettingsFile);
verifyqToxPath(paths->getLogFilePath(), cache, logFile);
verifyqToxPath(paths->getScreenshotsDir(), appData, screenshotsFolder % sep);
verifyqToxPath(paths->getTransfersDir(), appData, transfersFolder % sep);
@ -153,6 +155,7 @@ void TestPaths::checkPathsPortable()
verifyqToxPath(paths->getProfilesDir(), basePath, profileFolder % sep);
verifyqToxPath(paths->getGlobalSettingsPath(), basePath, globalSettingsFile);
verifyqToxPath(paths->getLogFilePath(), basePath, logFile);
verifyqToxPath(paths->getScreenshotsDir(), basePath, screenshotsFolder % sep);
verifyqToxPath(paths->getTransfersDir(), basePath, transfersFolder % sep);