-
Notifications
You must be signed in to change notification settings - Fork 2
/
fileHandling.h
32 lines (23 loc) · 893 Bytes
/
fileHandling.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef FILE_HANDLING_H
#define FILE_HANDLING_H
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
// getSize returns file size
uint32_t getSize(FILE* file);
// loadFile loads file into a char buffer
char* loadFile(FILE* file, uint32_t file_size);
// insert inserts n chars at specified location in the buffer,
// returns true if the operation was successful, false otherwise
bool insert(
char** buffer_ptr, uint32_t* buffer_len, char c, uint32_t index, uint32_t n
);
// append appends n chars to the end of the buffer,
// returns true if the operation was successful, false otherwise
bool append(char** buffer_ptr, uint32_t* buffer_len, char c, uint32_t n);
// checkExtension checks if the filename contains ext at the end
// Both filename and ext ought to be nul-terminated
bool checkExtension(char* filename, char* ext);
#endif