/*---------------------------------------------------------------------------*/ static void copy_file_from_romfs_to_cfs(const char * from, const char * to) { static char buf[128]; cfs_offset_t filesize, read, pos; /* Format CFS */ cfs_coffee_format(); /* Open file for writing in CFS */ int cfs_fd = cfs_open(to, CFS_WRITE); /* Open file for reading in ROMFS */ int rom_fd = romfs_open(from, CFS_READ); /* Determine file size */ filesize = romfs_seek(rom_fd, 0, CFS_SEEK_END) - 1; /* Restore offset to start of file */ romfs_seek(rom_fd, 0, CFS_SEEK_SET); /* Copy file data from romfs to cfs in chunks of 128 bytes */ for (pos = 0; pos < filesize; pos += read) { read = romfs_read(rom_fd, buf, sizeof(buf)); cfs_write(cfs_fd, buf, read); } /* Close both files */ cfs_close(cfs_fd); romfs_close(rom_fd); }
int32 RomfsStream::size() const { int32 oldPos = romfs_tell((ROMFILE *)_handle); romfs_seek((ROMFILE *)_handle, 0, SEEK_END); int32 length = romfs_tell((ROMFILE *)_handle); romfs_seek((ROMFILE *)_handle, oldPos, SEEK_SET); return length; }
bool RomfsStream::seek(int32 offs, int whence) { return romfs_seek((ROMFILE *)_handle, offs, whence) >= 0; }