libobs/util: Add os_rename function

Allows moving/renaming of files.
This commit is contained in:
jp9000
2015-06-21 22:33:48 -07:00
parent 7766f5a42f
commit 50f4793c99
3 changed files with 27 additions and 0 deletions

View File

@@ -413,6 +413,26 @@ int os_mkdir(const char *path)
return MKDIR_SUCCESS;
}
int os_rename(const char *old_path, const char *new_path)
{
wchar_t *old_path_utf16 = NULL;
wchar_t *new_path_utf16 = NULL;
int code = -1;
if (!os_utf8_to_wcs_ptr(old_path, 0, &old_path_utf16)) {
return -1;
}
if (!os_utf8_to_wcs_ptr(new_path, 0, &new_path_utf16)) {
goto error;
}
code = MoveFileW(old_path_utf16, new_path_utf16) ? 0 : -1;
error:
bfree(old_path_utf16);
bfree(new_path_utf16);
return code;
}
BOOL WINAPI DllMain(HINSTANCE hinst_dll, DWORD reason, LPVOID reserved)
{