ark: implement isReadOnly() for libarchive plugin

now the interface will properly indicate that the archive is not writable
when that is the case (it was not even before the port to KArchive)

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-12-22 02:09:04 +02:00
parent 4aaa9bbe6e
commit b024821c56
3 changed files with 11 additions and 3 deletions

View file

@ -168,10 +168,10 @@ bool ReadWriteArchiveInterface::isReadOnly() const
{
QFileInfo fileInfo(filename());
if (fileInfo.exists()) {
return ! fileInfo.isWritable();
} else {
return !fileInfo.dir().exists(); // TODO: Should also check if we can create a file in that directory
return !fileInfo.isWritable();
}
// TODO: Should also check if we can create a file in that directory
return !fileInfo.dir().exists();
}
} // namespace Kerfuffle

View file

@ -236,6 +236,12 @@ bool LibArchiveInterface::deleteFiles(const QVariantList &files)
return true;
}
bool LibArchiveInterface::isReadOnly() const
{
KArchive karchive(filename());
return !karchive.isWritable();
}
void LibArchiveInterface::emitProgress(const qreal value)
{
emit progress(value);

View file

@ -45,6 +45,8 @@ public:
bool addFiles(const QStringList& files, const CompressionOptions &options) final;
bool deleteFiles(const QVariantList& files) final;
bool isReadOnly() const final;
private Q_SLOTS:
void emitProgress(const qreal value);
};