ref: refs/heads/master
commit a32b62fc6cc5ce9c8cff99804176ae55116eb047
Author: Michael Andres
Date: Fri May 22 15:37:43 2009 +0200
Prevent makeSibling from cloning the mode if the siblings have different kind.
---
zypp/TmpPath.cc | 41 ++++++++++++++---------------------------
1 files changed, 14 insertions(+), 27 deletions(-)
diff --git a/zypp/TmpPath.cc b/zypp/TmpPath.cc
index b8e89c7..dbe44e5 100644
--- a/zypp/TmpPath.cc
+++ b/zypp/TmpPath.cc
@@ -172,17 +172,11 @@ namespace zypp {
const std::string & prefix_r )
{
// parent dir must exist
- PathInfo p( inParentDir_r );
- if ( ! p.isDir() )
- {
- filesystem::assert_dir( inParentDir_r );
- p(); // re-stat
- if ( ! p.isDir() )
- {
- ERR << "Parent directory can't be created: " << p << endl;
- return;
- }
- }
+ if ( filesystem::assert_dir( inParentDir_r ) != 0 )
+ {
+ ERR << "Parent directory '" << inParentDir_r << "' can't be created." << endl;
+ return;
+ }
// create the temp file
Pathname tmpPath = (inParentDir_r + prefix_r).extend( "XXXXXX");
@@ -190,7 +184,6 @@ namespace zypp {
if ( ! buf )
{
ERR << "Out of memory" << endl;
- ::free( buf );
return;
}
@@ -217,9 +210,9 @@ namespace zypp {
TmpFile ret( sibling_r.dirname(), sibling_r.basename() );
// clone mode if sibling_r exists
PathInfo p( sibling_r );
- if ( p.isExist() )
+ if ( p.isFile() )
{
- chmod( ret.path(), p.st_mode() );
+ ::chmod( ret.path().c_str(), p.st_mode() );
}
return ret;
}
@@ -251,17 +244,11 @@ namespace zypp {
const std::string & prefix_r )
{
// parent dir must exist
- PathInfo p( inParentDir_r );
- if ( ! p.isDir() )
- {
- filesystem::assert_dir( inParentDir_r );
- p(); // re-stat
- if ( ! p.isDir() )
- {
- ERR << "Parent directory does not exist: " << p << endl;
- return;
- }
- }
+ if ( filesystem::assert_dir( inParentDir_r ) != 0 )
+ {
+ ERR << "Parent directory '" << inParentDir_r << "' can't be created." << endl;
+ return;
+ }
// create the temp dir
Pathname tmpPath = (inParentDir_r + prefix_r).extend( "XXXXXX");
@@ -292,9 +279,9 @@ namespace zypp {
TmpDir ret( sibling_r.dirname(), sibling_r.basename() );
// clone mode if sibling_r exists
PathInfo p( sibling_r );
- if ( p.isExist() )
+ if ( p.isDir() )
{
- chmod( ret.path(), p.st_mode() );
+ ::chmod( ret.path().c_str(), p.st_mode() );
}
return ret;
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org