[go: up one dir, main page]

Menu

[r38]: / trunk / file.h  Maximize  Restore  History

Download this file

29 lines (22 with data), 997 Bytes

 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
/*
* This file is part of the uHex project.
* Copyright (C) Mateusz Viste 2015
*
* Provides a file-handling API with an integrated cache. This avoids to
* access the disk too frequently on cacheless systems, significantly speeding
* up the application when running from a diskette (or any other slow medium).
*/
#ifndef FILE_H_SENTINEL
#define FILE_H_SENTINEL
/* opens a file in given mode, returns the file's size on success, and a
* negative value on error. if error occurs, errvar is filled with errno. */
long file_open(char *fname, char *mode, int *errvar);
/* reads len bytes from file since position offset and writes them to
* bytebuff. returns the amount of bytes read (can be less than len if EOF
* reached). */
int file_read(unsigned char *bytebuff, int len, long offset);
/* writes a byte 'b' to file at position offset */
int file_writebyte(long offset, int b);
/* close the file and frees the cache memory */
void file_close(void);
#endif