Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[browserpaths] Move directory functions to dedicated module. Fixes JB…
…#32547
- Loading branch information
Showing
34 changed files
with
148 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2015 Jolla Ltd. | ||
** Contact: Dmitry Rozhkov <dmitry.rozhkov@jolla.com> | ||
** | ||
****************************************************************************/ | ||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include <QString> | ||
#include <QDir> | ||
#include <QStandardPaths> | ||
#include "browserpaths.h" | ||
|
||
static QString getLocation(QStandardPaths::StandardLocation locationType) { | ||
QString location(QStandardPaths::writableLocation(locationType)); | ||
QDir dir(location); | ||
if (!dir.exists()) { | ||
if (!dir.mkpath(location)) { | ||
qWarning(QString("Can't create directory ").append(location).toLatin1().data()) ; | ||
return QString(); | ||
} | ||
} | ||
|
||
return location; | ||
} | ||
|
||
QString BrowserPaths::downloadLocation() | ||
{ | ||
return getLocation(QStandardPaths::DownloadLocation); | ||
} | ||
|
||
QString BrowserPaths::picturesLocation() | ||
{ | ||
return getLocation(QStandardPaths::PicturesLocation); | ||
} | ||
|
||
QString BrowserPaths::dataLocation() | ||
{ | ||
return getLocation(QStandardPaths::DataLocation); | ||
} | ||
|
||
QString BrowserPaths::applicationsLocation() | ||
{ | ||
return getLocation(QStandardPaths::ApplicationsLocation); | ||
} | ||
|
||
QString BrowserPaths::cacheLocation() | ||
{ | ||
return getLocation(QStandardPaths::CacheLocation); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2015 Jolla Ltd. | ||
** Contact: Dmitry Rozhkov <dmitry.rozhkov@jolla.com> | ||
** | ||
****************************************************************************/ | ||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BROWSERPATHS_H | ||
#define BROWSERPATHS_H | ||
|
||
class QString; | ||
|
||
struct BrowserPaths | ||
{ | ||
static QString downloadLocation(); | ||
static QString picturesLocation(); | ||
static QString dataLocation(); | ||
static QString applicationsLocation(); | ||
static QString cacheLocation(); | ||
}; | ||
|
||
#endif // BROWSERPATHS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
INCLUDEPATH += $$PWD | ||
|
||
# C++ sources | ||
SOURCES += \ | ||
$$PWD/browserpaths.cpp \ | ||
|
||
# C++ headers | ||
HEADERS += \ | ||
$$PWD/browserpaths.h \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.