librostlab
1.0.20
|
00001 /* 00002 Copyright (C) 2011 Laszlo Kajan, Technical University of Munich, Germany 00003 00004 This file is part of librostlab. 00005 00006 librostlab is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU Lesser General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 #ifndef ROSTLAB_UMASK_RESOURCE 00020 #define ROSTLAB_UMASK_RESOURCE 1 00021 00022 #include <sys/types.h> 00023 #include <sys/stat.h> 00024 00025 namespace rostlab { 00026 00027 class umask_resource 00028 { 00029 private: 00030 mode_t _old_mode; 00031 // this is a resource - disable copy contructor and copy assignment 00032 umask_resource( const umask_resource& ){}; 00033 umask_resource& 00034 operator=(const umask_resource&){return *this;}; 00035 public: 00036 umask_resource( mode_t __new_mode ) : _old_mode( umask( __new_mode ) ) {}; 00037 virtual ~umask_resource(){ umask( _old_mode ); } 00038 }; 00039 00040 }; 00041 00042 #endif // ROSTLAB_UMASK_RESOURCE 00043 // vim:et:ts=2:ai: