1
0
Fork 0
mirror of https://github.com/bjornbytes/lovr.git synced 2024-07-02 12:33:52 +00:00

fs_open fails if you try to open a directory;

This commit is contained in:
bjorn 2023-11-22 16:19:45 -08:00
parent d949b90eea
commit 1ef562dcdd

View file

@ -199,8 +199,9 @@ bool fs_open(const char* path, char mode, fs_handle* file) {
case 'a': flags = O_APPEND | O_WRONLY | O_CREAT; break; case 'a': flags = O_APPEND | O_WRONLY | O_CREAT; break;
default: return false; default: return false;
} }
struct stat stats;
file->fd = open(path, flags, S_IRUSR | S_IWUSR); file->fd = open(path, flags, S_IRUSR | S_IWUSR);
return file->fd >= 0; return file->fd >= 0 && !fstat(file->fd, &stats) && !S_ISDIR(stats.st_mode);
} }
bool fs_close(fs_handle file) { bool fs_close(fs_handle file) {