gra-projekt/Implementierung/lib/io.h

33 lines
764 B
C
Raw Normal View History

2022-06-29 10:58:49 +02:00
#ifndef IO_H
#define IO_H
2022-06-29 21:29:15 +02:00
#define _XOPEN_SOURCE
2022-06-29 10:58:49 +02:00
#include <errno.h>
2022-06-29 20:54:41 +02:00
#include <stdbool.h>
2022-06-29 10:58:49 +02:00
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
2022-07-12 22:33:01 +02:00
/**
* @brief Open a file and load its stats
*
* @param path the filepath
* @param file where the pointer of the file handle should be stored
* @param file_stat pointer to a stat struct
* @return true it worked
* @return false there was an error
*/
bool open_file(const char* path, FILE** file, struct stat* file_stat);
2022-06-29 11:08:31 +02:00
/**
* @brief reads a file at a path
2022-06-29 11:12:35 +02:00
*
2022-06-29 11:08:31 +02:00
* @param path the filepath
* @param size a pointer where the size of the result should be stored
2022-06-29 22:02:18 +02:00
* @return pointer to the raw data or NULL on errors
2022-06-29 11:08:31 +02:00
*/
2022-06-29 22:02:18 +02:00
uint8_t* read_file(const char* path, size_t* size);
2022-06-29 11:08:31 +02:00
#endif // IO_H