Commit 5ed85e06 authored by Karel Slaný's avatar Karel Slaný

Replaced setDatovkaPath() with existingAppPath().

parent 6f525081
......@@ -50,7 +50,8 @@ void Files::declareQML(void)
qRegisterMetaType<Files::FileIdType>();
}
Files::Files(QObject *parent) : QObject(parent)
Files::Files(QObject *parent)
: QObject(parent)
{
}
......
......@@ -46,31 +46,29 @@ QString appAttachDirPath(void)
QString appCertDirPath(void)
{
return setDatovkaPath(dfltAttachSavingLoc(),
DATOVKA_CERT_DIR_NAME);
return existingAppPath(dfltAttachSavingLoc(), DATOVKA_CERT_DIR_NAME);
}
QString appEmailDirPath(const QString &msgIdStr)
{
return setDatovkaPath(dfltAttachSavingLoc(),
QString(DATOVKA_MAIL_DIR_NAME) + QDir::separator() + msgIdStr);
return existingAppPath(dfltAttachSavingLoc(),
QLatin1String(DATOVKA_MAIL_DIR_NAME) + QDir::separator() + msgIdStr);
}
QString appMsgAttachDirPath(const QString &msgIdStr)
{
return setDatovkaPath(dfltAttachSavingLoc(), msgIdStr);
return existingAppPath(dfltAttachSavingLoc(), msgIdStr);
}
QString appTmpDirPath(void)
{
return setDatovkaPath(dfltAttachSavingLoc(),
DATOVKA_TEMP_DIR_NAME);
return existingAppPath(dfltAttachSavingLoc(), DATOVKA_TEMP_DIR_NAME);
}
void removeDirFromDocLoc(const QString &dirName)
{
QString folderPath(
setDatovkaPath(dfltAttachSavingLoc(), dirName));
existingAppPath(dfltAttachSavingLoc(), dirName));
if (folderPath.isEmpty()) {
return;
......@@ -175,21 +173,18 @@ QString nonconflictingFileName(QString filePath)
return filePath;
}
QString setDatovkaPath(const QString &basePath, const QString &folderName)
QString existingAppPath(const QString &basePath, const QString &dirName)
{
QString newPath = basePath;
QString destPath(QLatin1String(DATOVKA_BASE_DIR_NAME) +
QDir::separator() + folderName);
QDir dir(basePath);
if (dir.mkpath(destPath)) {
newPath = basePath + QDir::separator() + destPath;
dir.setPath(newPath);
}
QString newPath = basePath + QDir::separator() +
QLatin1String(DATOVKA_BASE_DIR_NAME) + QDir::separator() + dirName;
if (!dir.exists()) {
qCritical("%s", "Location for file could not be created.");
QDir dir(newPath);
if (!dir.exists() && !dir.mkpath(".")) {
qCritical("Location '%s' could not be created.",
newPath.toUtf8().constData());
return QString();
}
Q_ASSERT(dir.exists());
return newPath;
}
......
......@@ -123,15 +123,18 @@ QStringList zfoFilesFromDir(const QString &dirPath, bool subdirs);
QString nonconflictingFileName(QString filePath);
/*!
* @brief Return path to directory in supplied base path. Create directory if it
* does not exist.
* @brief Return path to directory in supplied base path. Create directory if
* it does not exist.
*
* @note If "Base" and "Path" are supplied, then the resulting directory is
* going to be "Base/DATOVKA_BASE_DIR_NAME/Path".
*
* @param[in] basePath Base path.
* @param[in] dirName Directory name.
* @return Full path to directory in supplied base path if directory exists or
* it could be created. Empty sting otherwise.
*/
QString setDatovkaPath(const QString &basePath, const QString &folderName);
QString existingAppPath(const QString &basePath, const QString &dirName);
/*!
* @brief Create file and write data to it.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment