From a428058ded434f15da13704249cca9ec22c1a952 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 23 May 2009 23:56:08 +0000 Subject: [PATCH] * Copy the attributes before setting the destination's permissions. At least under Linux this caused trouble for files without write permission. * Fixed gcc4 warning. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30833 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/copyattr.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/bin/copyattr.cpp b/src/bin/copyattr.cpp index d772cd48a2..6683df6f7d 100644 --- a/src/bin/copyattr.cpp +++ b/src/bin/copyattr.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2005-2008, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2005-2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -431,6 +431,10 @@ copy_entry(const char *sourcePath, const char *destPath, exit(1); } + // copy attributes (before setting the permissions!) + copy_attributes(sourcePath, *sourceNode, destPath, *destNode, + parameters); + // set file owner, group, permissions, times destNode->SetOwner(sourceStat.st_uid); destNode->SetGroup(sourceStat.st_gid); @@ -450,10 +454,11 @@ copy_entry(const char *sourcePath, const char *destPath, } destNode = &_destNode; - } - // copy attributes - copy_attributes(sourcePath, *sourceNode, destPath, *destNode, parameters); + // copy attributes + copy_attributes(sourcePath, *sourceNode, destPath, *destNode, + parameters); + } // the destination node is no longer needed destNode->Unset(); @@ -583,8 +588,8 @@ copy_files(const char **sourcePaths, int sourceCount, // If the path is the root directory or the leaf is "." or "..", // we copy the contents only. int leafLen = sourceLen - leafStart; - if (leafLen == 0 || leafLen <= 2 - && strncmp(sourcePath + leafStart, "..", leafLen) == 0) { + if (leafLen == 0 || (leafLen <= 2 + && strncmp(sourcePath + leafStart, "..", leafLen) == 0)) { copySourceContentsOnly = true; } }