Pulsar  3d3a057
archive_file.h
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief Shared archive file management
4  * @note These should not be needed directly, use the wrapped archive functions instead
5  */
6 #pragma once
7 
8 #include <pulsar/types.h>
9 
10 #define PLSR_INVALID_ARCHIVE_FILE_HANDLE NULL
11 
12 typedef struct {
13  FILE* f;
14  char* context;
15  size_t refs;
17 
19 
20 PLSR_ArchiveFileHandle plsrArchiveFileOpen(const char* path, bool storePath);
21 
22 void plsrArchiveFileClose(PLSR_ArchiveFileHandle handle);
23 PLSR_ArchiveFileHandle plsrArchiveFileCloneHandle(PLSR_ArchiveFileHandle handle);
24 bool plsrArchiveFileRelativePath(PLSR_ArchiveFileHandle handle, const char* path, char* out, size_t size);
25 
26 NX_INLINE bool plsrArchiveFileRead(PLSR_ArchiveFileHandle handle, void* out, size_t size) {
27  return handle && fread(out, size, 1, handle->f) == 1;
28 }
29 
30 NX_INLINE bool plsrArchiveFileSetPosition(PLSR_ArchiveFileHandle handle, long offset) {
31  return handle && fseek(handle->f, offset, SEEK_SET) != -1;
32 }
33 
34 NX_INLINE bool plsrArchiveFileReadString(PLSR_ArchiveFileHandle handle, char* out, size_t size) {
35  return handle && fgets(out, size, handle->f) != NULL;
36 }
Base types.
Definition: archive_file.h:12