3 * (c) 2005-2009 Laurent Vivier <Laurent@vivier.eu>
5 * This file has been copied from EMILE, http://emile.sf.net
9 #include "libiso9660.h"
10 #include "libopenbios/bindings.h"
11 #include "libc/diskio.h"
13 size_t iso9660_read(iso9660_FILE
*_file
, char *buf
, size_t count
)
15 iso9660_FILE
*file
= (iso9660_FILE
*)_file
;
18 if ( count
> (file
->size
- file
->offset
) )
19 count
= file
->size
- file
->offset
;
27 offset_extent
= file
->base
+
28 (file
->offset
/ ISOFS_BLOCK_SIZE
);
29 offset_index
= file
->offset
% ISOFS_BLOCK_SIZE
;
31 if (file
->current
!= offset_extent
)
33 if ( (offset_index
== 0) &&
34 (count
>= ISOFS_BLOCK_SIZE
) )
40 extents_nb
= count
/ ISOFS_BLOCK_SIZE
;
42 part
= extents_nb
* ISOFS_BLOCK_SIZE
;
44 seek_io(file
->volume
->fd
,
45 offset_extent
* ISOFS_BLOCK_SIZE
);
46 read_io(file
->volume
->fd
, buf
+ read
, part
);
55 file
->current
= offset_extent
;
56 seek_io(file
->volume
->fd
,
57 offset_extent
* ISOFS_BLOCK_SIZE
);
58 read_io(file
->volume
->fd
, file
->buffer
,
62 part
= ISOFS_BLOCK_SIZE
- offset_index
;
66 memcpy(buf
+ read
, file
->buffer
+ offset_index
, part
);