20#ifndef LIBREPCB_CORE_TRANSACTIONALDIRECTORY_H
21#define LIBREPCB_CORE_TRANSACTIONALDIRECTORY_H
37class TransactionalFileSystem;
58 const QString& dir =
"",
59 QObject* parent =
nullptr)
noexcept;
66 const QString& subdir =
"",
67 QObject* parent =
nullptr)
noexcept;
84 virtual QStringList
getDirs(const QString& path = "") const noexcept override;
86 const QString& path = "") const noexcept override;
87 virtual
bool fileExists(const QString& path) const noexcept override;
88 virtual QByteArray
read(const QString& path) const override;
89 virtual QByteArray
readIfExists(const QString& path) const override;
90 virtual
void write(const QString& path, const QByteArray& content) override;
91 virtual
void renameFile(const QString& src, const QString& dst) override;
92 virtual
void removeFile(const QString& path) override;
102 const QString& srcDir,
104 const QString& dstDir);
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
Helper class to access a subdirectory of TransactionalFileSystem.
Definition: transactionaldirectory.h:51
std::shared_ptr< TransactionalFileSystem > getFileSystem() noexcept
Definition: transactionaldirectory.h:75
virtual void removeDirRecursively(const QString &path="") override
Definition: transactionaldirectory.cpp:120
TransactionalDirectory(QObject *parent=nullptr)
Definition: transactionaldirectory.cpp:36
const QString & getPath() const noexcept
Definition: transactionaldirectory.h:78
virtual bool fileExists(const QString &path) const noexcept override
Definition: transactionaldirectory.cpp:94
virtual QStringList getFiles(const QString &path="") const noexcept override
Definition: transactionaldirectory.cpp:89
virtual void renameFile(const QString &src, const QString &dst) override
Definition: transactionaldirectory.cpp:111
virtual void write(const QString &path, const QByteArray &content) override
Definition: transactionaldirectory.cpp:106
void saveTo(TransactionalDirectory &dest)
Definition: transactionaldirectory.cpp:136
virtual QStringList getDirs(const QString &path="") const noexcept override
Definition: transactionaldirectory.cpp:84
QString mPath
Definition: transactionaldirectory.h:108
bool isRestoredFromAutosave() const noexcept
Definition: transactionaldirectory.cpp:71
virtual void removeFile(const QString &path) override
Definition: transactionaldirectory.cpp:116
virtual QByteArray read(const QString &path) const override
Definition: transactionaldirectory.cpp:98
void copyTo(TransactionalDirectory &dest) const
Definition: transactionaldirectory.cpp:128
std::shared_ptr< TransactionalFileSystem > mFileSystem
Definition: transactionaldirectory.h:107
std::shared_ptr< const TransactionalFileSystem > getFileSystem() const noexcept
Definition: transactionaldirectory.h:71
virtual ~TransactionalDirectory() noexcept
Definition: transactionaldirectory.cpp:60
bool isWritable() const noexcept
Definition: transactionaldirectory.cpp:67
void moveTo(TransactionalDirectory &dest)
Definition: transactionaldirectory.cpp:145
static void copyDirRecursively(TransactionalFileSystem &srcFs, const QString &srcDir, TransactionalFileSystem &dstFs, const QString &dstDir)
Definition: transactionaldirectory.cpp:161
virtual QByteArray readIfExists(const QString &path) const override
Definition: transactionaldirectory.cpp:102
virtual FilePath getAbsPath(const QString &path="") const noexcept override
Definition: transactionaldirectory.cpp:79
Transactional librepcb::FileSystem implementation.
Definition: transactionalfilesystem.h:71
Definition: occmodel.cpp:77