From 0b57aa2b77ec299151f5515bcb0627533f4245b6 Mon Sep 17 00:00:00 2001 From: Morgan Koh Date: Tue, 2 Jun 2026 16:33:16 +0200 Subject: [PATCH] Replace manual trash implementation with NSFileManager's trashItemAtURL --- GitUpKit/Core/GCFoundation.m | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/GitUpKit/Core/GCFoundation.m b/GitUpKit/Core/GCFoundation.m index 2e88281ab..15c893b91 100644 --- a/GitUpKit/Core/GCFoundation.m +++ b/GitUpKit/Core/GCFoundation.m @@ -39,19 +39,7 @@ - (BOOL)fileExistsAtPath:(NSString*)path followLastSymlink:(BOOL)followLastSymli #if !TARGET_OS_IPHONE - (BOOL)moveItemAtPathToTrash:(NSString*)path error:(NSError**)error { - NSString* trashPath = [NSSearchPathForDirectoriesInDomains(NSTrashDirectory, NSUserDomainMask, YES) firstObject]; - if (!trashPath) { - GC_SET_GENERIC_ERROR(@"Unable to find Trash"); - return NO; - } - NSString* extension = path.pathExtension; - NSString* name = [path.lastPathComponent stringByDeletingPathExtension]; - NSString* destinationPath = [trashPath stringByAppendingPathComponent:[name stringByAppendingPathExtension:extension]]; - NSUInteger counter = 0; - while ([self fileExistsAtPath:destinationPath followLastSymlink:NO]) { - destinationPath = [trashPath stringByAppendingPathComponent:[[NSString stringWithFormat:@"%@ (%lu)", name, ++counter] stringByAppendingPathExtension:extension]]; - } - return [self moveItemAtPath:path toPath:destinationPath error:error]; + return [self trashItemAtURL:[NSURL fileURLWithPath:path] resultingItemURL:NULL error:error]; } #endif