Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions GitUpKit/Core/GCFoundation.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading