コード例 #1
0
ファイル: romfsstream.cpp プロジェクト: MatChung/scummvm-ps3
RomfsStream *RomfsStream::makeFromPath(const Common::String &path, bool writeMode) {
	ROMFILE *handle = romfs_open(path.c_str(), writeMode ? "wb" : "rb");

	if (handle)
		return new RomfsStream(handle);
	return 0;
}
コード例 #2
0
ファイル: display-test.c プロジェクト: EasyRF/contiki
/*---------------------------------------------------------------------------*/
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);
}
コード例 #3
0
ファイル: n64-fs.cpp プロジェクト: 0xf1sh/scummvm
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);
	}
}