Split g_file_open() into _ro() and _rw() variants

Rename g_file_open() to g_file_open_rw(), and add a new g_file_open_ro()
call that wraps the common g_file_open_ex(file, 1, 0, 0, 0) idiom. This
will make the file access mode more explicit in the code.

Change all calls to g_file_open() to the _ro() or _rw() variant as
appropriate, and replace g_file_open_ex(file, 1, 0, 0, 0) with the _ro()
call.

Lastly, add tests for the two new calls to test_os_calls.c (code
courteously provided by matt335672).
This commit is contained in:
Daniel Richard G
2023-05-13 01:54:32 -04:00
parent 4b37e1a508
commit 1c0c923ad1
24 changed files with 103 additions and 60 deletions
+1 -1
View File
@@ -170,7 +170,7 @@ fv1_file_load(const char *filename)
int fd;
make_stream(s);
init_stream(s, file_size + 1024);
fd = g_file_open(filename);
fd = g_file_open_ro(filename);
if (fd < 0)
{
+1 -1
View File
@@ -155,7 +155,7 @@ font_dump(void)
g_snprintf(filename, 255, "%s-%d.fv1", g_font_name, g_font_size);
msg("creating file %s", filename);
g_file_delete(filename);
fd = g_file_open(filename);
fd = g_file_open_rw(filename);
g_file_write(fd, "FNT1", 4);
strlen1 = g_strlen(g_font_name);
g_file_write(fd, g_font_name, strlen1);