xref: /aosp_15_r20/external/libbrillo/brillo/scoped_umask.cc (revision 1a96fba65179ea7d3f56207137718607415c5953)
1*1a96fba6SXin Li // Copyright 2019 The Chromium OS Authors. All rights reserved.
2*1a96fba6SXin Li // Use of this source code is governed by a BSD-style license that can be
3*1a96fba6SXin Li // found in the LICENSE file.
4*1a96fba6SXin Li 
5*1a96fba6SXin Li #include "brillo/scoped_umask.h"
6*1a96fba6SXin Li 
7*1a96fba6SXin Li #include <sys/stat.h>
8*1a96fba6SXin Li 
9*1a96fba6SXin Li namespace brillo {
10*1a96fba6SXin Li 
ScopedUmask(mode_t new_umask)11*1a96fba6SXin Li ScopedUmask::ScopedUmask(mode_t new_umask) {
12*1a96fba6SXin Li   saved_umask_ = umask(new_umask);
13*1a96fba6SXin Li }
14*1a96fba6SXin Li 
~ScopedUmask()15*1a96fba6SXin Li ScopedUmask::~ScopedUmask() {
16*1a96fba6SXin Li   umask(saved_umask_);
17*1a96fba6SXin Li }
18*1a96fba6SXin Li 
19*1a96fba6SXin Li }  // namespace brillo
20