summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore/UmaskScope.h
blob: f77c22956d7287fc0e6643172ae0fc99a216b990 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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 {};
};

}