mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2025-05-18 23:39:17 +02:00
25 lines
600 B
C
25 lines
600 B
C
#include "fygue.h"
|
|
|
|
/* fygue_file_read(): read file data */
|
|
ssize_t fygue_file_read(
|
|
struct fygue_fsinfo *fsinfo,
|
|
struct fygue_file *file,
|
|
void *buffer,
|
|
size_t size
|
|
) {
|
|
ssize_t read;
|
|
|
|
if (fsinfo == NULL || file == NULL)
|
|
FYGUE_RET_ERRNO(EIO);
|
|
if (buffer == NULL)
|
|
FYGUE_RET_ERRNO(EFAULT);
|
|
if (file->cursor > 0 && (unsigned)file->cursor >= file->size)
|
|
return 0;
|
|
if (file->cursor + size >= file->size)
|
|
size = file->size - file->cursor;
|
|
read = fygue_fat_file_read(&(fsinfo->fat), &(file->fat), buffer, size);
|
|
if (read < 0)
|
|
FYGUE_RET_ERRNO(EIO);
|
|
file->cursor += read;
|
|
return read;
|
|
}
|