D6829: Add ability to use the new kauth helper in file ioslave
Chinmoy Ranjan Pradhan
noreply at phabricator.kde.org
Thu Aug 24 01:49:54 UTC 2017
chinmoyr added a comment.
Actually, I like this construct quite a bit.
if (!dir.rmdir(itemPath)) {
if (auto ret = execWithElevatedPrivilege(RMDIR, itemPath)) {
if (!ret.wasCanceled()) {
error(KIO::ERR_CANNOT_DELETE, itemPath);
}
return false;
}
}
But for this to work the class should be something like this
class ExecWithElevatedPrivilegeReturnValue
{
public:
static ExecWithElevatedPrivilegeReturnValue success() { return ExecWithElevatedPrivilegeReturnValue{false, false}; }
static ExecWithElevatedPrivilegeReturnValue failure() { return ExecWithElevatedPrivilegeReturnValue{true, false}; }
static ExecWithElevatedPrivilegeReturnValue canceled() { return ExecWithElevatedPrivilegeReturnValue{true, true}; }
operator bool() const { return m_failed; }
bool wasCanceled() const { return m_canceled; }
private:
ExecWithElevatedPrivilegeReturnValue(bool failed, bool canceled) : m_failed(failed), m_canceled(canceled) {}
const bool m_failed;
const bool m_canceled;
};
am I correct?
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/2bf3c253/attachment.html>
More information about the Kde-frameworks-devel
mailing list