LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_FILESYSTEM_H
21 #define LIBREPCB_FILESYSTEM_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "filepath.h"
27 
28 #include <QtCore>
29 
30 /*******************************************************************************
31  * Namespace / Forward Declarations
32  ******************************************************************************/
33 
34 namespace librepcb {
35 
36 /*******************************************************************************
37  * Class FileSystem
38  ******************************************************************************/
39 
43 class FileSystem : public QObject {
44  Q_OBJECT
45 
46 public:
47  // Constructors / Destructor
48  FileSystem(QObject* parent = nullptr) noexcept : QObject(parent) {}
49  virtual ~FileSystem() noexcept {}
50 
51  // File Operations
52  virtual FilePath getAbsPath(const QString& path = "") const noexcept = 0;
53  virtual QStringList getDirs(const QString& path = "") const noexcept = 0;
54  virtual QStringList getFiles(const QString& path = "") const noexcept = 0;
55  virtual bool fileExists(const QString& path) const noexcept = 0;
56  virtual QByteArray read(const QString& path) const = 0;
57  virtual void write(const QString& path, const QByteArray& content) = 0;
58  virtual void removeFile(const QString& path) = 0;
59  virtual void removeDirRecursively(const QString& path = "") = 0;
60 };
61 
62 /*******************************************************************************
63  * End of File
64  ******************************************************************************/
65 
66 } // namespace librepcb
67 
68 #endif // LIBREPCB_FILESYSTEM_H
virtual void removeFile(const QString &path)=0
virtual bool fileExists(const QString &path) const noexcept=0
FileSystem(QObject *parent=nullptr) noexcept
Definition: filesystem.h:48
virtual ~FileSystem() noexcept
Definition: filesystem.h:49
virtual void write(const QString &path, const QByteArray &content)=0
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
virtual FilePath getAbsPath(const QString &path="") const noexcept=0
virtual QByteArray read(const QString &path) const =0
virtual QStringList getFiles(const QString &path="") const noexcept=0
Base class / interface for all file system implementations.
Definition: filesystem.h:43
virtual QStringList getDirs(const QString &path="") const noexcept=0
virtual void removeDirRecursively(const QString &path="")=0