From 5ea68724ff6b49d935101246de38ffd955d57f50 Mon Sep 17 00:00:00 2001 From: rfm Date: Sun, 3 Nov 2024 13:15:20 +0000 Subject: [PATCH] Fix for issue 452 --- ChangeLog | 5 +++++ Source/NSFileManager.m | 32 +++++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index acac637ca..8e48ea21e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2024-11-03 Richard Frith-Macdonald + + * Source/NSFileManager.m: Fix case where positive result of asking + handler whether to proceed was ignored. + 2024-11-01 Richard Frith-Macdonald * Source/NSDate.m: Fix returing receiver when earlier/later argument diff --git a/Source/NSFileManager.m b/Source/NSFileManager.m index ebba409d8..ee1772b7c 100644 --- a/Source/NSFileManager.m +++ b/Source/NSFileManager.m @@ -1386,11 +1386,30 @@ - (BOOL) copyPath: (NSString*)source if ([self createDirectoryAtPath: destination attributes: attrs] == NO) { - return [self _proceedAccordingToHandler: handler - forError: [self _lastError] - inPath: destination - fromPath: source - toPath: destination]; + if (NO == [self _proceedAccordingToHandler: handler + forError: [self _lastError] + inPath: destination + fromPath: source + toPath: destination]) + { + return NO; + } + else + { + BOOL dirOK; + + /* We may have managed to create the directory but not set + * its attributes ... if so we can continue copying. + */ + if (![self fileExistsAtPath: destination isDirectory: &dirOK]) + { + dirOK = NO; + } + if (!dirOK) + { + return NO; + } + } } if ([self _copyPath: source toPath: destination handler: handler] == NO) @@ -3419,8 +3438,7 @@ - (BOOL) _copyPath: (NSString*)source result = NO; break; } - /* - * We may have managed to create the directory but not set + /* We may have managed to create the directory but not set * its attributes ... if so we can continue copying. */ if (![self fileExistsAtPath: destinationFile isDirectory: &dirOK])