Added OS::move_path_to_trash function, implemented only on OS X for now.
This commit is contained in:
parent
253db95cba
commit
b0d5596738
|
@ -334,6 +334,8 @@ public:
|
|||
virtual String get_data_dir() const;
|
||||
virtual String get_resource_dir() const;
|
||||
|
||||
virtual Error move_path_to_trash(String p_dir) { return FAILED; }
|
||||
|
||||
enum SystemDir {
|
||||
SYSTEM_DIR_DESKTOP,
|
||||
SYSTEM_DIR_DCIM,
|
||||
|
|
|
@ -220,6 +220,8 @@ public:
|
|||
void disable_crash_handler();
|
||||
bool is_disable_crash_handler() const;
|
||||
|
||||
virtual Error move_path_to_trash(String p_dir);
|
||||
|
||||
OS_OSX();
|
||||
};
|
||||
|
||||
|
|
|
@ -1797,6 +1797,19 @@ String OS_OSX::get_joy_guid(int p_device) const {
|
|||
return input->get_joy_guid_remapped(p_device);
|
||||
}
|
||||
|
||||
Error OS_OSX::move_path_to_trash(String p_dir) {
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
NSURL *url = [NSURL fileURLWithPath:@(p_dir.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() {
|
||||
|
|
Loading…
Reference in New Issue