diff --git a/ChangeLog b/ChangeLog index ffb854247..ff326d865 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-06-23 Richard Frith-Macdonald + + * Source/NSFileManager.m: Don't attempt to set ownership of copied + file. The code was already doing this right for directories, but + not for other file types. + 2013-06-21 Lubos Dolezel * Headers/GSBlocks.h: weakly import _Block_copy and _Block_release diff --git a/Source/NSFileManager.m b/Source/NSFileManager.m index 6e03c9d02..3ac2fef53 100644 --- a/Source/NSFileManager.m +++ b/Source/NSFileManager.m @@ -1039,32 +1039,33 @@ static NSStringEncoding defaultEncoding; return NO; } fileType = [attrs fileType]; + + /* + * Don't attempt to retain ownership of copy ... we want the copy + * to be owned by the current user. + */ + attrs = AUTORELEASE([attrs mutableCopy]); + [(NSMutableDictionary*)attrs removeObjectForKey: NSFileOwnerAccountID]; + [(NSMutableDictionary*)attrs removeObjectForKey: NSFileGroupOwnerAccountID]; + (NSMutableDictionary*)mattrs removeObjectForKey: NSFileGroupOwnerAccountName]; + (NSMutableDictionary*)mattrs setObject: NSUserName() + forKey: NSFileOwnerAccountName]; + if ([fileType isEqualToString: NSFileTypeDirectory] == YES) { - NSMutableDictionary *mattrs; /* If destination directory is a descendant of source directory copying isn't possible. */ if ([[destination stringByAppendingString: @"/"] hasPrefix: [source stringByAppendingString: @"/"]]) { - ASSIGN(_lastError, @"Could not copy - destination is a descendant of source"); + ASSIGN(_lastError, + @"Could not copy - destination is a descendant of source"); return NO; } [self _sendToHandler: handler willProcessPath: destination]; - /* - * Don't attempt to retain ownership of copy ... we want the copy - * to be owned by the current user. - */ - mattrs = [attrs mutableCopy]; - [mattrs removeObjectForKey: NSFileOwnerAccountID]; - [mattrs removeObjectForKey: NSFileGroupOwnerAccountID]; - [mattrs removeObjectForKey: NSFileGroupOwnerAccountName]; - [mattrs setObject: NSUserName() forKey: NSFileOwnerAccountName]; - attrs = AUTORELEASE(mattrs); - if ([self createDirectoryAtPath: destination attributes: attrs] == NO) { return [self _proceedAccordingToHandler: handler