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:
parent
c6ce606e47
commit
edd8f19a1b
1 changed files with 30 additions and 0 deletions
30
Userland/Libraries/LibCore/UmaskScope.h
Normal file
30
Userland/Libraries/LibCore/UmaskScope.h
Normal 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 {};
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue