From a3a409b438e4b9b53af154d149d7956b83be4ddc Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 14 Nov 2020 12:53:24 +0000 Subject: [PATCH] Fix crash bug when deleting files with spaces in names. --- libs/kiplatform/osx/environment.mm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libs/kiplatform/osx/environment.mm b/libs/kiplatform/osx/environment.mm index 4e0913a53e..440b8b088c 100644 --- a/libs/kiplatform/osx/environment.mm +++ b/libs/kiplatform/osx/environment.mm @@ -22,13 +22,12 @@ #import #include - +#include bool KIPLATFORM::ENV::MoveToTrash( const wxString& aPath, wxString& aError ) { - wxString temp = "file:///" + aPath; - - NSURL* url = [NSURL URLWithString:wxCFStringRef( temp ).AsNSString()]; + bool isDirectory = wxDirExists( aPath ); + NSURL* url = [NSURL fileURLWithPath:wxCFStringRef( aPath ).AsNSString() isDirectory:isDirectory]; NSError* err = NULL; BOOL result = [[NSFileManager defaultManager] trashItemAtURL:url resultingItemURL:nil error:&err];