IO functions

This commit is contained in:
2023-10-21 18:58:09 +01:00
parent 362b1b33d5
commit d7792998ea
2 changed files with 201 additions and 0 deletions

22
include/io.h Normal file
View File

@@ -0,0 +1,22 @@
#ifndef IO_H
#define IO_H
#include "aliases.h"
#include <linux/limits.h>
#include <stdbool.h>
#include <stdio.h>
#define STREQ(S1, S2) (strcmp(S1, S2) == 0)
typedef struct dirwalk dirwalk_t;
typedef struct {
FILE *fp;
bool reading;
char name[NAME_MAX + 1];
} dirwalk_result_t;
u64 get_file_length(FILE *fp);
void read_entire_file(void *dst, u64 length, FILE *fp);
dirwalk_result_t walk_dir(dirwalk_t **dirwalk, const char *filepath);
#endif // !IO_H