[Interest] QFile/QDir: force move mode only?
giuseppe.dangelo at kdab.com
Tue May 14 16:15:39 CEST 2019
On 14/05/2019 15:47, Jason H wrote:
> I'd rather static bool QFile::isAtomicRename(const QString &source, cont QString &dest);
> So that the software can plan accordingly. Blindly executing won't allow the software to accomodate non-atomic renames (i.e. Display an alternate UI). It would also be nice if there was an atomic-esque non-atomic rename, that would be a copy to the target FS and then atomic rename.
Such a function would be inherently racy (the moment you have that
information, the information is already outdated, as the filesystem may
have changed). Suppose the function returns true, you then call
QFile::rename() and may end up copying anyway.
(I can't also think of an API at the OS level that could answer your
question -- rename(2), link(2) etc. are all "destructive" syscalls. But
maybe there is some trick.)
However: KIO::rename fails if the rename cannot be performed, and you
can then use move:
Not entirely sure how to fix QFile::rename for this purpose (maybe
adding a flag, making it fail if the rename requires a copy), or if it's
even worth it given KIO exists.
My 2 c,
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4329 bytes
Desc: S/MIME Cryptographic Signature
More information about the Interest