-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcd_fileclient.c
51 lines (37 loc) · 1.11 KB
/
cd_fileclient.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
#include <yaul.h>
#include <sys/cdefs.h>
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
static uint8_t _sector[FILECLIENT_SECTOR_SIZE];
void
cd_init(void)
{
}
void
cd_load(const char *filename, void *dst, uint32_t read_size)
{
uint8_t *dst_p;
dst_p = dst;
const uint32_t sector_count = fileclient_sector_count_request(filename);
const uint32_t calc_sector_count = min(sector_count, (read_size >> 11) + 1);
for (uint32_t sector = 0; sector < calc_sector_count; sector++) {
fileclient_sector_request(filename, sector, _sector);
const uint32_t copy_len = min(read_size, ISO9660_SECTOR_SIZE);
(void)memcpy(dst_p, _sector, copy_len);
dst_p += copy_len;
}
}
int32_t
cd_load_nosize(char *filename, void *dst)
{
const uint32_t byte_size = fileclient_byte_size_request(filename);
cd_load(filename, dst, byte_size);
return byte_size;
}
uint32_t
cd_byte_size_get(const char *filename)
{
const uint32_t byte_size = fileclient_byte_size_request(filename);
return byte_size;
}