1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:27:46 +00:00

LibCore: Add Core::UmaskScope to set and unset a temporary umask

This commit is contained in:
Andreas Kling 2022-01-01 19:49:35 +01:00
parent c6ce606e47
commit edd8f19a1b

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <sys/stat.h>
#include <sys/types.h>
#pragma once
namespace Core {
class UmaskScope {
public:
explicit UmaskScope(mode_t mask)
{
m_old_mask = umask(mask);
}
~UmaskScope()
{
umask(m_old_mask);
}
private:
mode_t m_old_mask {};
};
}