1 /* 2 Drawpile - a collaborative drawing program. 3 4 Copyright (C) 2015-2019 Calle Laakkonen 5 6 Drawpile is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 Drawpile is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with Drawpile. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 #ifndef PATHS_H 20 #define PATHS_H 21 22 #include <QStandardPaths> 23 24 namespace utils { 25 namespace paths { 26 27 //! Override the default read-only data paths 28 void setDataPath(const QString &datapath); 29 30 /** 31 * @brief Override the writable data path 32 * 33 * If you're overriding both read-only and writable data paths, 34 * setDataPath must be called first. 35 */ 36 void setWritablePath(const QString &datapath); 37 38 /** 39 * @brief Get a list of paths in which datafiles may reside 40 */ 41 QStringList dataPaths(); 42 43 /** 44 * @brief Locate a file in dataPaths 45 * 46 * Returns the first file found or an empty string if not. 47 */ 48 QString locateDataFile(const QString &filename); 49 50 /** 51 * @brief Get the full path to a writable directory or file. 52 * 53 * If both dirOrFilename and filename are given, the dirOrFilename should contain a directory component. 54 * That directory is created first, if it doesn't exist already. 55 */ 56 QString writablePath(QStandardPaths::StandardLocation location, const QString &dirOrFileName, const QString &filename=QString()); 57 58 inline QString writablePath(const QString &dirOrFileName, const QString &filename=QString()) 59 { 60 return writablePath(QStandardPaths::AppDataLocation, dirOrFileName, filename); 61 } 62 63 } 64 } 65 66 #endif 67