|
|
@@ -34,6 +34,7 @@ enum file_err file_save(const char *filepath, const char *str, size_t str_size);
|
|
|
|
|
|
#include <unistd.h>
|
|
|
#include <fcntl.h>
|
|
|
+#include <sys/stat.h>
|
|
|
|
|
|
struct ret_void_p_err
|
|
|
file_read_all(const char *filepath)
|
|
|
@@ -109,7 +110,9 @@ err: ;
|
|
|
enum file_err
|
|
|
file_save(const char *filepath, const char *str, size_t str_size)
|
|
|
{
|
|
|
- int32_t fd = open(filepath, O_WRONLY);
|
|
|
+ int32_t fd = open(filepath,
|
|
|
+ O_WRONLY | O_CREAT | O_TRUNC,
|
|
|
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
|
|
if ( fd < 0 ) {
|
|
|
return FILE_ERR_FAIL_OPEN;
|
|
|
}
|