Mailinglist Archive: zypp-commit (232 mails)

< Previous Next >
[zypp-commit] <libzypp> SuSE-Code-11-Branch : Add filesystem::addmode/delmode to add/delete specific permissson bits.
  • From: Michael Andres <ma@xxxxxxx>
  • Date: Fri, 27 Nov 2009 10:58:38 +0100
  • Message-id: <E1NDxts-0001AX-OV@xxxxxxxxxxxxxxxx>
ref: refs/heads/SuSE-Code-11-Branch
commit 8a84da9f77266c161ec8bc3c41dcb826b4cbde14
Author: Michael Andres <ma@xxxxxxx>
Date: Fri Nov 27 10:55:23 2009 +0100

Add filesystem::addmode/delmode to add/delete specific permissson bits.
---
zypp/PathInfo.cc | 20 +++++++++++++++++++-
zypp/PathInfo.h | 14 ++++++++++++++
2 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/zypp/PathInfo.cc b/zypp/PathInfo.cc
index 3a4b4cf..6646aec 100644
--- a/zypp/PathInfo.cc
+++ b/zypp/PathInfo.cc
@@ -921,7 +921,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 bb88e80..c5348ea 100644
--- a/zypp/PathInfo.h
+++ b/zypp/PathInfo.h
@@ -649,6 +649,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 );
//@}

///////////////////////////////////////////////////////////////////
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages