-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_handler.h
41 lines (31 loc) · 873 Bytes
/
file_handler.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
33
34
35
36
37
38
39
40
41
#pragma once
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#ifndef FILE_HANDLER
#define FILE_HANDLER
// file string
typedef struct file_string{
char * file_data;
size_t size;
char *filename;
} fstr;
// Create a new file_string.
fstr *file_string_open(char * filename);
// close file_string.
void file_string_close(fstr *f);
// Write the data to file;
void file_string_write(fstr *f);
//delete char from given index
void file_string_remove_char(fstr *f,size_t i);
//Apend to the file_string
void file_string_append(fstr *f, char c);
//insert char at given index into file_string
void file_string_insert_char(fstr *f,char c, size_t i);
// Get char at index i from file_string
char file_string_get_char(fstr *f,size_t i);
// Get the size of the file_string.
size_t file_string_get_size(fstr *f);
#endif