From 00b282dcd4ce35d0b8bdd53bccf8497ce43f5ad6 Mon Sep 17 00:00:00 2001 From: Martin Fouilleul Date: Fri, 26 Aug 2022 14:47:20 +0200 Subject: [PATCH] Platform file system functions (remove, move, etc) --- src/mp_app.h | 1 + src/osx_app.m | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/mp_app.h b/src/mp_app.h index 03e5afd..0c6f954 100644 --- a/src/mp_app.h +++ b/src/mp_app.h @@ -416,6 +416,7 @@ int mp_alert_popup(const char* title, // file system stuff... //TODO: move elsewhere //-------------------------------------------------------------------- int mp_file_move(str8 from, str8 to); +int mp_file_remove(str8 path); #ifdef __cplusplus } // extern "C" diff --git a/src/osx_app.m b/src/osx_app.m index 63db0c5..26dcc81 100644 --- a/src/osx_app.m +++ b/src/osx_app.m @@ -2635,5 +2635,18 @@ int mp_file_move(str8 from, str8 to) } }} +int mp_file_remove(str8 path) +{@autoreleasepool{ + NSString* nsPath = [[NSString alloc] initWithBytes:path.ptr length:path.len encoding: NSUTF8StringEncoding]; + NSError* err; + if([[NSFileManager defaultManager] removeItemAtPath:nsPath error:&err] == YES) + { + return(0); + } + else + { + return(-1); + } +}} #undef LOG_SUBSYSTEM