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>
#include <wx/osx/core/cfstring.h>
#include <wx/filefn.h>
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];