KIO::FileCopyJob Class

class KIO::FileCopyJob
Header: #include <KIO/FileCopyJob>
CMake: find_package(KF6 REQUIRED COMPONENTS KIO)
target_link_libraries(mytarget PRIVATE KF6::KIOCore)
Inherits: KIO::Job

Public Functions

QUrl destUrl() const
void setModificationTime(const QDateTime &mtime)
void setSourceSize(KIO::filesize_t size)
QUrl srcUrl() const

Signals

(since 5.78) void mimeTypeFound(KIO::Job *job, const QString &mimeType)

Protected Slots

virtual void slotResult(KJob *job) override
KIO::FileCopyJob *file_copy(const QUrl &src, const QUrl &dest, KIO::JobFlags flags)
KIO::FileCopyJob *file_copy(const QUrl &src, const QUrl &dest, int permissions = -1, KIO::JobFlags flags = DefaultFlags)
KIO::FileCopyJob *file_move(const QUrl &src, const QUrl &dest, int permissions = -1, KIO::JobFlags flags = DefaultFlags)

Detailed Description

The FileCopyJob copies data from one place to another.

See also KIO::file_copy() and KIO::file_move().

Member Function Documentation

QUrl FileCopyJob::destUrl() const

Returns the destination URL

[signal, since 5.78] void FileCopyJob::mimeTypeFound(KIO::Job *job, const QString &mimeType)

MIME type determined during a file copy. This is never emitted during a move, and might not be emitted during a file copy, depending on the worker. But when a get and a put are being used (which is the common case), this signal forwards the MIME type information from the get job.

job the job that emitted this signal

mimeType the MIME type

This function was introduced in 5.78.

void FileCopyJob::setModificationTime(const QDateTime &mtime)

Sets the modification time of the file

Note that this is ignored if a direct copy (WorkerBase::copy) can be done, in which case the mtime of the source is applied to the destination (if the protocol supports the concept).

void FileCopyJob::setSourceSize(KIO::filesize_t size)

If you know the size of the source file, call this method to inform this job. It will be displayed in the "resume" dialog.

size the size of the source file

[override virtual protected slot] void FileCopyJob::slotResult(KJob *job)

Reimplements: KCompositeJob::slotResult(KJob *job).

Called whenever a subjob finishes.

job the job that emitted this signal

QUrl FileCopyJob::srcUrl() const

Returns the source URL

Related Non-Members

KIO::FileCopyJob *file_copy(const QUrl &src, const QUrl &dest, KIO::JobFlags flags)

Overload for catching code mistakes. Do NOT call this method (it is not implemented), insert a value for permissions (-1 by default) before the JobFlags.

KIO::FileCopyJob *file_copy(const QUrl &src, const QUrl &dest, int permissions = -1, KIO::JobFlags flags = DefaultFlags)

Copy a single file.

Uses either WorkerBase::copy() if the worker supports that or get() and put() otherwise.

src Where to get the file

dest Where to put the file

permissions the file mode permissions to set on dest; if this is -1 (the default) no special permissions will be set on dest, i.e. it'll have the default system permissions for newly created files, and the owner and group permissions are not preserved.

flags Can be JobFlag::HideProgressInfo, Overwrite and Resume here WARNING: Setting JobFlag::Resume means that the data will be appended to dest if dest exists

Returns the job handling the operation

KIO::FileCopyJob *file_move(const QUrl &src, const QUrl &dest, int permissions = -1, KIO::JobFlags flags = DefaultFlags)

Move a single file.

Use either WorkerBase::rename() if the worker supports that, or copy() and del() otherwise, or eventually get() & put() & del()

src Where to get the file

dest Where to put the file

permissions the file mode permissions to set on dest; if this is -1 (the default), no special permissions are set on dest, i.e. it'll have the default system permissions for newly created files, and the owner and group permissions are not preserved.

flags Can be HideProgressInfo, Overwrite and Resume here WARNING: Setting JobFlag::Resume means that the data will be appended to dest if dest exists

Returns the job handling the operation