[Interest] QFile/QDir: force move mode only?
Giuseppe D'Angelo
giuseppe.dangelo at kdab.com
Tue May 14 16:15:39 CEST 2019
Hi,
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:
> https://api.kde.org/frameworks/kio/html/namespaceKIO.html#a399cbd217c9a897db18ea247fb289c84
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...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4329 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190514/bbacd6d9/attachment.bin>
More information about the Interest
mailing list