Skip to content

Commit

Permalink
asset: fix must_open when used in tools on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rasky committed Jan 6, 2025
1 parent 53c2b5d commit 9e8e53f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/asset.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
#include <string.h>
#include <errno.h>
#include <stdalign.h>
#include <sys/stat.h>

#ifndef O_BINARY
#define O_BINARY 0
#endif

#ifdef N64
#include <malloc.h>
Expand Down Expand Up @@ -67,7 +72,7 @@ void __asset_init_compression_lvl3(void)

int must_open(const char *fn)
{
int fd = open(fn, O_RDONLY);
int fd = open(fn, O_RDONLY|O_BINARY);
if (fd < 0) {
// File not found.
int errnum = errno;
Expand All @@ -76,13 +81,13 @@ int must_open(const char *fn)
// A common mistake is to forget the filesystem prefix.
// Try to give a hint if that's the case.
assertf(fd >= 0, "File not found: %s\n"
"Did you forget the filesystem prefix? (e.g. \"rom:/\")\n", fn);
"Did you forget the filesystem prefix? (e.g. \"rom:/\")", fn);
return -1;
} else if (strstr(fn, "rom:/")) {
// Another common mistake is to forget to initialize the rom filesystem.
// Suggest that if the filesystem prefix is "rom:/".
assertf(fd >= 0, "File not found: %s\n"
"Did you forget to call dfs_init(), or did it return an error?\n", fn);
"Did you forget to call dfs_init(), or did it return an error?", fn);
return -1;
}
}
Expand Down

0 comments on commit 9e8e53f

Please sign in to comment.