1#include "include/pw.h"
2#include "include/pwlib/file.h"
3#include "include/pwlib/path.h"
4
5[[nodiscard]] bool pw_rename_file(PwValuePtr old_filename, PwValuePtr new_filename)
6{
7 PwValue old_filename_str = PW_NULL;
8 if (!pw_path_as_string(old_filename, &old_filename_str)) {
9 return false;
10 }
11 PwValue new_filename_str = PW_NULL;
12 if (!pw_path_as_string(new_filename, &new_filename_str)) {
13 return false;
14 }
15 PW_CSTRING(old, &old_filename_str);
16 PW_CSTRING(new, &new_filename_str);
17 if (rename(old, new) == -1) {
18 pw_set_status(PwErrno(errno));
19 return false;
20 }
21 return true;
22}