/*---------------------------------------------------------------------------*/ 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); }
N64FilesystemNode::N64FilesystemNode(const Common::String &p, bool verify) { assert(p.size() > 0); _path = p; _displayName = lastPathComponent(_path, '/'); _isValid = true; _isDirectory = true; // Check if it's a dir ROMFILE *tmpfd = romfs_open(p.c_str(), "r"); if (tmpfd) { _isDirectory = (tmpfd->type == 0 || tmpfd->type == 1); romfs_close(tmpfd); } }
RomfsStream::~RomfsStream() { romfs_close((ROMFILE *)_handle); }