Adding plaform specific move file functions

This commit is contained in:
Martin Fouilleul 2022-08-21 19:14:59 +02:00
parent 1d77a36640
commit 884e05abd2
2 changed files with 26 additions and 0 deletions

View File

@ -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

View File

@ -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