From 5e0f185a148dc991cb77885a2e0120c4a78e20f2 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Fri, 27 Nov 2009 10:55:23 +0100 Subject: [PATCH] Add filesystem::addmode/delmode to add/delete specific permissson bits. --- zypp/PathInfo.cc | 20 +++++++++++++++++++- zypp/PathInfo.h | 14 ++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/zypp/PathInfo.cc b/zypp/PathInfo.cc index 25bec31..a8aa743 100644 --- a/zypp/PathInfo.cc +++ b/zypp/PathInfo.cc @@ -1017,7 +1017,25 @@ namespace zypp return _Log_Result( 0 ); } - /////////////////////////////////////////////////////////////////// + int addmod( const Pathname & path, mode_t mode ) + { + mode_t omode( PathInfo( path ).st_mode() ); + mode_t tmode( omode | mode ); + if ( omode != mode ) + return chmod( path, tmode ); + return 0; + } + + int delmod( const Pathname & path, mode_t mode ) + { + mode_t omode( PathInfo( path ).st_mode() ); + mode_t tmode( omode & ~mode ); + if ( omode != mode ) + return chmod( path, tmode ); + return 0; + } + + ////////////////////////////////////////////////////////////////// // // METHOD NAME : zipType // METHOD TYPE : ZIP_TYPE diff --git a/zypp/PathInfo.h b/zypp/PathInfo.h index 43376f8..e5ddf2d 100644 --- a/zypp/PathInfo.h +++ b/zypp/PathInfo.h @@ -693,6 +693,20 @@ namespace zypp * @return 0 on success, errno on failure **/ int chmod( const Pathname & path, mode_t mode ); + + /** + * Add the \c mode bits to the file given by path. + * + * @return 0 on success, errno on failure + */ + int addmod( const Pathname & path, mode_t mode ); + + /** + * Remove the \c mode bits from the file given by path. + * + * @return 0 on success, errno on failure + */ + int delmod( const Pathname & path, mode_t mode ); //@} /////////////////////////////////////////////////////////////////// -- 2.7.4