Debian Codegraph @

src/librssguard/miscellaneous/iofactory.h

raw symbols SCIP
1 // For license of this file, see <project-root-folder>/LICENSE.md.
2
3 #ifndef IOFACTORY_H
4 #define IOFACTORY_H
5
6 #include "definitions/definitions.h"
7
8 #include <QCoreApplication>
9 #include <QProcessEnvironment>
10 #include <QStandardPaths>
11
12 class RSSGUARD_DLLSPEC IOFactory {
13 Q_DECLARE_TR_FUNCTIONS(IOFactory)
14
15 private:
16 IOFactory();
17
18 public:
19 static bool isFolderWritable(const QString& folder);
20
21 // Returns system-wide folder according to type.
22 static QString getSystemFolder(QStandardPaths::StandardLocation location);
23
24 // Checks given file if it exists and if it does, then generates non-existing new file
25 // according to format.
26 static QString ensureUniqueFilename(const QString& name, const QString& append_format = QSL("(%1)"));
27
28 // Filters out shit characters from filename.
29 static QString filterBadCharsFromFilename(const QString& name);
30 static bool startProcessDetached(const QString& executable,
31 const QStringList& arguments = {},
32 const QString& working_directory = {});
33 static void startProcess(QProcess* const proc,
34 const QString& executable,
35 const QStringList& arguments = {},
36 const QProcessEnvironment& pe = {},
37 const QString& working_directory = {});
38 static QString startProcessGetOutput(const QString& executable,
39 const QStringList& arguments = {},
40 const QProcessEnvironment& pe = {},
41 const QString& working_directory = {});
42
43 // Returns contents of a file.
44 // Throws exception when no such file exists.
45 static QByteArray readFile(const QString& file_path);
46 static void writeFile(const QString& file_path, const QByteArray& data);
47
48 // Copies file, overwrites destination.
49 static bool copyFile(const QString& source, const QString& destination);
50
51 static void removeFolder(const QString& path);
52 };
53
54 #endif // IOFACTORY_H