summaryrefslogtreecommitdiffstats
path: root/file_use.h
blob: 8b0ac66ea3b871769b228351de2f21b614c97cb5 (plain) (blame)
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
42
#ifndef __LIBUTILS_FILE_USE_H
#define __LIBUTILS_FILE_USE_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "debug.h"

#define F_FILE_NONE  0
#define F_FILE_READ  1
#define F_FILE_WRITE 2
#define F_FILE_RW    3


#define F_SEEK_CUR SEEK_CUR
#define F_SEEK_END SEEK_END
#define F_SEEK_SET SEEK_SET

//simple file using things
typedef struct f_file
{
	FILE *fid;	
	int flags;
	long size;
	int seek;
} f_file;

void f_file_null( f_file* );
int f_file_seek( f_file*, long, int );
size_t f_file_read( f_file*, size_t, void* );
size_t f_file_readl( f_file*, size_t, void* ); //read until readline, return how much readed
//f_file_read_bl();
int f_file_size( f_file* );
size_t f_file_write( f_file*, size_t, void* );
//f_file_write_bl();
f_file* f_file_open( const char*, int );
int f_file_close( f_file* );
//f_file_flush();
//f_file_mmap();

#endif