KIO::FuseMountJob Class
class KIO::FuseMountJobFuseMountJob makes a URL reachable through a local path using kio-fuse. More...
| Header: | #include <KIO/FuseMountJob> |
| CMake: | find_package(KF6 REQUIRED COMPONENTS KIO)target_link_libraries(mytarget PRIVATE KF6::KIOCore) |
| Since: | 6.33 |
| Inherits: | KJob |
Public Functions
| FuseMountJob(const QUrl &url, QObject *parent = nullptr) | |
| QString | localPath() const |
| void | setTimeout(int msecs) |
| QUrl | url() const |
Reimplemented Public Functions
| virtual void | start() override |
Detailed Description
This is useful for handing files from any KIO location to code that only understands local paths, e.g. a library that expects a file name.
The job asks the kio-fuse service to mount the URL and returns the local path where it is reachable. The service is started on demand if it is installed. A local file URL is returned as its path without mounting.
If kio-fuse is not available, the job fails with KIO::ERR_UNSUPPORTED_ACTION, which lets callers fall back to another approach, e.g. copying the file. This is also the case when KIO was built without D-Bus support.
auto *job = new KIO::FuseMountJob(url, this);
connect(job, &KJob::result, this, [job]() {
if (!job->error()) {
const QString path = job->localPath();
...
}
});
job->start();
Member Function Documentation
[explicit] FuseMountJob::FuseMountJob(const QUrl &url, QObject *parent = nullptr)
Creates a FuseMountJob for url.
QString FuseMountJob::localPath() const
Returns the local path where url() is reachable.
Call this in a slot connected to the result() signal, and only after making sure no error happened.
void FuseMountJob::setTimeout(int msecs)
Sets how long to wait for kio-fuse, in milliseconds, before failing with KIO::ERR_SERVER_TIMEOUT.
By default there is no timeout, since mounting can involve asking the user for a password. Kill the job to stop waiting.
Must be called before start().
[override virtual] void FuseMountJob::start()
Reimplements: KJob::start().
Starts the job.
QUrl FuseMountJob::url() const
Returns the URL the job was created for.