From 884e05abd29d72932153f8b6a56cf9e34a65c192 Mon Sep 17 00:00:00 2001 From: Martin Fouilleul Date: Sun, 21 Aug 2022 19:14:59 +0200 Subject: [PATCH] Adding plaform specific move file functions --- src/mp_app.h | 6 ++++++ src/osx_app.m | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/mp_app.h b/src/mp_app.h index cf5e3c3..03e5afd 100644 --- a/src/mp_app.h +++ b/src/mp_app.h @@ -411,6 +411,12 @@ int mp_alert_popup(const char* title, u32 count, const char** options); + +//-------------------------------------------------------------------- +// file system stuff... //TODO: move elsewhere +//-------------------------------------------------------------------- +int mp_file_move(str8 from, str8 to); + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/osx_app.m b/src/osx_app.m index 13ce595..63db0c5 100644 --- a/src/osx_app.m +++ b/src/osx_app.m @@ -2616,4 +2616,24 @@ int mp_alert_popup(const char* title, } +//-------------------------------------------------------------------- +// file system stuff... //TODO: move elsewhere +//-------------------------------------------------------------------- + +int mp_file_move(str8 from, str8 to) +{@autoreleasepool{ + NSString* nsFrom = [[NSString alloc] initWithBytes:from.ptr length:from.len encoding: NSUTF8StringEncoding]; + NSString* nsTo = [[NSString alloc] initWithBytes:to.ptr length:to.len encoding: NSUTF8StringEncoding]; + NSError* err; + if([[NSFileManager defaultManager] moveItemAtPath:nsFrom toPath:nsTo error:&err] == YES) + { + return(0); + } + else + { + return(-1); + } +}} + + #undef LOG_SUBSYSTEM