diff options
author | Marcelo Fernandez <marcelofg55@gmail.com> | 2017-09-25 10:15:11 -0300 |
---|---|---|
committer | Marcelo Fernandez <marcelofg55@gmail.com> | 2017-09-25 21:49:01 -0300 |
commit | 20918587d39c5c9c370e3b4beccf883f553d9b3e (patch) | |
tree | b0035e8e35dbe0d4cbf97dc6a05e946bcbd5dc64 /platform/osx | |
parent | 09800ac65079599c568679b53962a313182885ea (diff) |
FileSystemDock will now remove files/dirs to trashcan using OS::move_to_trash
Diffstat (limited to 'platform/osx')
-rw-r--r-- | platform/osx/os_osx.h | 2 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 6c81da04f5..3542453d70 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -229,6 +229,8 @@ public: void disable_crash_handler(); bool is_disable_crash_handler() const; + virtual Error move_to_trash(const String &p_path); + OS_OSX(); }; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 9a26adc155..0e6e1a2c43 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1910,6 +1910,19 @@ int OS_OSX::get_power_percent_left() { return power_manager->get_power_percent_left(); } +Error OS_OSX::move_to_trash(const String &p_path) { + NSFileManager *fm = [NSFileManager defaultManager]; + NSURL *url = [NSURL fileURLWithPath:@(p_path.utf8().get_data())]; + NSError *err; + + if (![fm trashItemAtURL:url resultingItemURL:nil error:&err]) { + ERR_PRINTS("trashItemAtURL error: " + String(err.localizedDescription.UTF8String)); + return FAILED; + } + + return OK; +} + OS_OSX *OS_OSX::singleton = NULL; OS_OSX::OS_OSX() { |