Platform file system functions (remove, move, etc)

This commit is contained in:
Martin Fouilleul 2022-08-26 14:47:20 +02:00
parent 884e05abd2
commit 00b282dcd4
2 changed files with 14 additions and 0 deletions

View File

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

View File

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