Skip to content

Commit

Permalink
Add explicit check for PRISM_HAS_NO_FILESYSTEM
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun authored and kddnewton committed Jul 26, 2024
1 parent b3d9064 commit 89c22f0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions include/prism/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@
# endif
#endif

/**
* If PRISM_HAS_NO_FILESYSTEM is defined, then we want to exclude all filesystem
* related code from the library. All filesystem related code should be guarded
* by PRISM_HAS_FILESYSTEM.
*/
#ifndef PRISM_HAS_NO_FILESYSTEM
# define PRISM_HAS_FILESYSTEM
#endif

/**
* isinf on Windows is defined as accepting a float, but on POSIX systems it
* accepts a float, a double, or a long double. We want to mirror this behavior
Expand Down
7 changes: 6 additions & 1 deletion src/util/pm_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pm_string_file_init(pm_string_t *string, const char *filepath) {
CloseHandle(file);
*string = (pm_string_t) { .type = PM_STRING_OWNED, .source = source, .length = (size_t) file_size };
return true;
#else
#elif defined(PRISM_HAS_FILESYSTEM)
FILE *file = fopen(filepath, "rb");
if (file == NULL) {
return false;
Expand Down Expand Up @@ -241,6 +241,11 @@ pm_string_file_init(pm_string_t *string, const char *filepath) {

*string = (pm_string_t) { .type = PM_STRING_OWNED, .source = source, .length = length };
return true;
#else
(void) string;
(void) filepath;
perror("pm_string_file_init is not implemented for this platform");
return false;
#endif
}

Expand Down

0 comments on commit 89c22f0

Please sign in to comment.