D6829: Add ability to use the new kauth helper in file ioslave
David Faure
noreply at phabricator.kde.org
Thu Aug 24 17:15:47 UTC 2017
dfaure accepted this revision.
dfaure added a comment.
This revision is now accepted and ready to land.
Oh I see, sorry for the bug in operator bool() in my suggested code. It reads strange that operator bool() returns true on failure, but .... yeah it's the most common use case for this class. Make sure to add a comment in that class docu, it's surely going to surprise someone some day, just like it just surprised me despite me writing the pseudo-code for it ;)
Something like this...
/**
* PrivilegeOperationReturnValue encapsulates the return value from execWithElevatedPrivilege() in a convenient way.
* Warning, this class will cast to a bool that is false on success and true on failure. This unusual solution allows to write
* kioslave code like this:
if (!dir.rmdir(itemPath)) {
if (auto ret = execWithElevatedPrivilege(RMDIR, itemPath)) {
if (!ret.wasCanceled()) {
error(KIO::ERR_CANNOT_DELETE, itemPath);
}
return false;
}
}
// directory successfully removed, continue with the next operation
*/
BRANCH
second
REVISION DETAIL
https://phabricator.kde.org/D6829
To: chinmoyr, dfaure, #frameworks
Cc: #frameworks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20170824/cf06f198/attachment-0001.html>
More information about the Kde-frameworks-devel
mailing list