Sayonara Player
Loading...
Searching...
No Matches
FileSystem.h
1/* FileSystem.h */
2/*
3 * Copyright (C) 2011-2024 Michael Lugmair
4 *
5 * This file is part of sayonara player
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef SAYONARA_PLAYER_FILESYSTEM_H
22#define SAYONARA_PLAYER_FILESYSTEM_H
23
24#include <QDir>
25#include <QString>
26#include <QStringList>
27
28#include <optional>
29#include <memory>
30
31namespace Util
32{
34 {
35 public:
36 FileSystem();
37 virtual ~FileSystem() noexcept;
38
39 FileSystem(const FileSystem& other) = delete;
40 FileSystem(FileSystem&& other) = delete;
41 FileSystem& operator=(const FileSystem& other) = delete;
42 FileSystem& operator=(FileSystem&& other) = delete;
43
44 virtual bool isDir(const QString& filename) = 0;
45 virtual bool isFile(const QString& filename) = 0;
46 virtual bool createDirectories(const QString& path) = 0;
47 virtual bool exists(const QString& filename) = 0;
48 virtual bool writeFile(const QByteArray& data, const QString& filename) = 0;
49 virtual QString readFileIntoString(const QString& filename) = 0;
50 virtual bool copyFile(const QString& sourceFile, const QString& targetFile) = 0;
51 virtual void deleteFiles(const QStringList& files) = 0;
52 [[nodiscard]] virtual QStringList
53 entryList(const QDir& dir, const QStringList& nameFilters, QDir::Filters filters) const = 0;
54 [[nodiscard]] virtual QStringList entryList(const QDir& dir, QDir::Filters filters) const final;
55
56 [[nodiscard]] virtual std::optional<QDir> cd(const QDir& dir, const QString& subDir) const = 0;
57
58 static std::shared_ptr<FileSystem> create();
59 };
60
61 using FileSystemPtr = std::shared_ptr<FileSystem>;
62}
63#endif //SAYONARA_PLAYER_FILESYSTEM_H
Definition: FileSystem.h:34
Helper functions.
Definition: MetaTypeRegistry.h:25