lovr/src/core/fs.h

33 lines
925 B
C
Raw Normal View History

2019-11-23 21:15:33 +00:00
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#pragma once
typedef enum {
FILE_DIRECTORY,
FILE_REGULAR
} FileType;
typedef struct {
uint64_t size;
uint64_t lastModified;
FileType type;
} FileInfo;
2019-11-25 01:27:17 +00:00
typedef void fs_list_cb(void*, const char*);
2019-12-06 01:54:04 +00:00
typedef union { int fd; void* handle; } fs_handle;
2019-11-23 21:15:33 +00:00
2023-11-22 02:47:56 +00:00
bool fs_open(const char* path, char mode, fs_handle* file);
2019-11-23 21:15:33 +00:00
bool fs_close(fs_handle file);
bool fs_read(fs_handle file, void* data, size_t size, size_t* count);
bool fs_write(fs_handle file, const void* data, size_t size, size_t* count);
2023-11-22 02:47:56 +00:00
bool fs_seek(fs_handle file, uint64_t offset);
bool fs_fstat(fs_handle file, FileInfo* info);
2019-11-25 01:27:17 +00:00
void* fs_map(const char* path, size_t* size);
bool fs_unmap(void* data, size_t size);
2019-11-23 21:15:33 +00:00
bool fs_stat(const char* path, FileInfo* info);
bool fs_remove(const char* path);
bool fs_mkdir(const char* path);
bool fs_list(const char* path, fs_list_cb* callback, void* context);