-
Notifications
You must be signed in to change notification settings - Fork 3
/
JUDASIO.C
55 lines (48 loc) · 1.16 KB
/
JUDASIO.C
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
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* JUDAS file I/O functions. Used by sample/music loading. If you
* use a datafile system and/or compression in your program, just modify these
* functions appropriately. JUDAS needs to do the following:
* - open file (in readonly binary mode)
* - read from file
* - seek
* - close file
*/
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#ifdef __DJGPP__
#include <sys/stat.h> /* for mode definitions */
#include <unistd.h> /* compatibility mode */
#endif
int judas_open(char *name);
int judas_seek(int handle, int bytes, int whence);
int judas_read(int handle, void *buffer, int size);
void judas_close(int handle);
/*
* Returns nonnegative file handle if successful, -1 on error
*/
int judas_open(char *name)
{
return open(name, O_RDONLY | O_BINARY);
}
/*
* Returns file position after seek or -1 on error
*/
int judas_seek(int handle, int bytes, int whence)
{
return lseek(handle, bytes, whence);
}
/*
* Returns number of bytes actually read, -1 on error
*/
int judas_read(int handle, void *buffer, int size)
{
return read(handle, buffer, size);
}
/*
* Returns nothing
*/
void judas_close(int handle)
{
close(handle);
}