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.dang...@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

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to