LibrePCB Developers Documentation
filesystem.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program 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 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_CORE_FILESYSTEM_H
21#define LIBREPCB_CORE_FILESYSTEM_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "filepath.h"
27
28#include <QtCore>
29
30/*******************************************************************************
31 * Namespace / Forward Declarations
32 ******************************************************************************/
33namespace librepcb {
34
35/*******************************************************************************
36 * Class FileSystem
37 ******************************************************************************/
38
45class FileSystem : public QObject {
46 Q_OBJECT
47
48public:
49 // Constructors / Destructor
50 FileSystem(QObject* parent = nullptr) noexcept : QObject(parent) {}
51 virtual ~FileSystem() noexcept {}
52
53 // File Operations
54 virtual FilePath getAbsPath(const QString& path = "") const noexcept = 0;
55 virtual QStringList getDirs(const QString& path = "") const noexcept = 0;
56 virtual QStringList getFiles(const QString& path = "") const noexcept = 0;
57 virtual bool fileExists(const QString& path) const noexcept = 0;
58 virtual QByteArray read(const QString& path) const = 0;
59 virtual QByteArray readIfExists(const QString& path) const = 0;
60 virtual void write(const QString& path, const QByteArray& content) = 0;
61 virtual void renameFile(const QString& src, const QString& dst) = 0;
62 virtual void removeFile(const QString& path) = 0;
63 virtual void removeDirRecursively(const QString& path = "") = 0;
64};
65
66/*******************************************************************************
67 * End of File
68 ******************************************************************************/
69
70} // namespace librepcb
71
72#endif
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:129
Base class / interface for all file system implementations.
Definition: filesystem.h:45
virtual QByteArray read(const QString &path) const =0
virtual FilePath getAbsPath(const QString &path="") const noexcept=0
virtual void removeDirRecursively(const QString &path="")=0
virtual bool fileExists(const QString &path) const noexcept=0
FileSystem(QObject *parent=nullptr) noexcept
Definition: filesystem.h:50
virtual ~FileSystem() noexcept
Definition: filesystem.h:51
virtual void write(const QString &path, const QByteArray &content)=0
virtual void removeFile(const QString &path)=0
virtual void renameFile(const QString &src, const QString &dst)=0
virtual QStringList getFiles(const QString &path="") const noexcept=0
virtual QStringList getDirs(const QString &path="") const noexcept=0
virtual QByteArray readIfExists(const QString &path) const =0
Definition: occmodel.cpp:77