1#include "include/pw.h"
 2#include "include/pwlib/file.h"
 3
 4[[nodiscard]] bool pw_write_file(PwValuePtr filename, PwValuePtr content)
 5{
 6    PwValue f = PW_NULL;
 7    if (!pw_file_open_unbuffered(filename, O_CREAT | O_TRUNC | O_WRONLY, 0666, &f)) {
 8        return false;
 9    }
10    PwStringIter iter;
11    _pw_string_iter(content, &iter);
12    bool ret = pw_write(&f, iter.start_ptr, (unsigned) (iter.end_ptr - iter.start_ptr), nullptr);
13    pw_close(&f);
14    return ret;
15}