diff options
author | David Robillard <d@drobilla.net> | 2018-05-10 20:59:45 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-05-27 18:23:15 +0200 |
commit | a3b6babaf0186b34d801a75b62253573ef26a154 (patch) | |
tree | 22d0d45a45827da2025073660a38c0a39f5fbba3 /src/world.c | |
parent | 8d1dcc05f7072651c0056221d00d8f1bf3fb80a1 (diff) | |
download | serd-a3b6babaf0186b34d801a75b62253573ef26a154.tar.gz serd-a3b6babaf0186b34d801a75b62253573ef26a154.tar.bz2 serd-a3b6babaf0186b34d801a75b62253573ef26a154.zip |
Hide fopen wrapper and use reader interface consistently
Diffstat (limited to 'src/world.c')
-rw-r--r-- | src/world.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/world.c b/src/world.c index 55ea4559..62517f88 100644 --- a/src/world.c +++ b/src/world.c @@ -14,12 +14,35 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#define _POSIX_C_SOURCE 200809L /* for posix_fadvise */ + #include "serd_internal.h" +#include "serd_config.h" #include <stdarg.h> +#include <stdio.h> +#if defined(HAVE_POSIX_FADVISE) +# include <fcntl.h> +#endif #include "world.h" +FILE* +serd_world_fopen(SerdWorld* world, const char* path, const char* mode) +{ + FILE* fd = fopen(path, mode); + if (!fd) { + serd_world_errorf(world, SERD_ERR_INTERNAL, + "failed to open file %s (%s)\n", + path, strerror(errno)); + return NULL; + } +#if defined(HAVE_POSIX_FADVISE) && defined(HAVE_FILENO) + posix_fadvise(fileno(fd), 0, 0, POSIX_FADV_SEQUENTIAL); +#endif + return fd; +} + SerdStatus serd_world_error(const SerdWorld* world, const SerdError* e) { |