Fix crash bug when deleting files with spaces in names.

This commit is contained in:
Jeff Young 2020-11-14 12:53:24 +00:00
parent f35736cdd7
commit a3a409b438
1 changed files with 3 additions and 4 deletions

View File

@ -22,13 +22,12 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include <wx/osx/core/cfstring.h> #include <wx/osx/core/cfstring.h>
#include <wx/filefn.h>
bool KIPLATFORM::ENV::MoveToTrash( const wxString& aPath, wxString& aError ) bool KIPLATFORM::ENV::MoveToTrash( const wxString& aPath, wxString& aError )
{ {
wxString temp = "file:///" + aPath; bool isDirectory = wxDirExists( aPath );
NSURL* url = [NSURL fileURLWithPath:wxCFStringRef( aPath ).AsNSString() isDirectory:isDirectory];
NSURL* url = [NSURL URLWithString:wxCFStringRef( temp ).AsNSString()];
NSError* err = NULL; NSError* err = NULL;
BOOL result = [[NSFileManager defaultManager] trashItemAtURL:url resultingItemURL:nil error:&err]; BOOL result = [[NSFileManager defaultManager] trashItemAtURL:url resultingItemURL:nil error:&err];