Exemplo n.º 1
0
int op_extract_iso(char *code, char *filename, void (*update)(int, int))
{
  FILE *f;
  wbfs_disc_t *disc;

  cancel_wbfs_op = 0;
  if (! update)
    update = progress_update;

  /* open disc */
  disc = wbfs_open_disc(app_state.wbfs, (u8 *) code);
  if (disc == NULL) {
    show_error("Error Extracting ISO", "Can't find disc id '%s'", code);
    return 1;
  }

  /* open ISO */
  f = fopen(filename, "w");
  if (f == NULL) {
    show_error("Error Extracting ISO", "Can't open ISO file '%s'", filename);
    wbfs_close_disc(disc);
    return 1;
  }

  wbfs_file_reserve_space(f, (disc->p->n_wii_sec_per_disc/2) * 0x8000ULL);
  wbfs_extract_disc(disc, write_wii_sector_file, (void *) f, update);

  fclose(f);
  wbfs_close_disc(disc);
  return 0;
}
Exemplo n.º 2
0
s32 WBFS_OpenDisc(u8 *discid)
{
	s32 ret;

	/* Initialize USB */
	ret = usbstorage_Startup();
	if (!ret)
		return 1;

	/* Read capacity */
	ret = usbstorage_ReadCapacity(&sectorSz, &nbSector);
	if (!ret)
		return 2;

	/* Close disc */
	if (disc)
		wbfs_close_disc(disc);

	/* Close SD */
	if (hdd)
		wbfs_close(hdd);

	/* Open SD */
	hdd = wbfs_open_hd(__WBFS_ReadSector, NULL, NULL, sectorSz, 0, 0);
	if (!hdd)
		return 3;

	/* Open disc */
	disc = wbfs_open_disc(hdd, discid);
	if (!disc)
		return 4;

	return 0;
}
Exemplo n.º 3
0
s32 WBFS_GameSize(u8 *discid, f32 *size)
{
	wbfs_disc_t *disc = NULL;

	u32 sectors;

	/* No device open */
	if (!hdd)
		return -1;

	/* Open disc */
	disc = wbfs_open_disc(hdd, discid);
	if (!disc)
		return -2;

	/* Get game size in sectors */
	sectors = wbfs_sector_used(hdd, disc->header);

	/* Close disc */
	wbfs_close_disc(disc);

	/* Copy value */
	*size = (hdd->wbfs_sec_sz / GB_SIZE) * sectors;

	return 0;
}
Exemplo n.º 4
0
s32 WBFS_OpenDisc(u8 *discid)
{
	s32 ret;

	/* Initialize SDIO */
	ret = sdio_Startup();
	if (!ret)
		return 1;

	/* Close disc */
	if (disc)
		wbfs_close_disc(disc);

	/* Close SD */
	if (hdd)
		wbfs_close(hdd);

	/* Open SD */
	hdd = wbfs_open_hd(__WBFS_ReadSector, NULL, NULL, SECTOR_SIZE, 0, 0);
	if (!hdd)
		return 2;

	/* Open disc */
	disc = wbfs_open_disc(hdd, discid);
	if (!disc)
		return 3;

	return 0;
}
Exemplo n.º 5
0
void WBFS_CloseDisc(wbfs_disc_t *disc)
{
	if (wbfs_part_fs) {
		WBFS_FAT_CloseDisc(disc);
	} else {
		if (hdd && disc) {
			/* Close disc */
			wbfs_close_disc(disc);
		}
	}
	if (disc) {
		LWP_MutexUnlock(wbfs_disc_mutex);
	}
}
Exemplo n.º 6
0
s32 WBFS_CheckGame(u8 *discid)
{
	wbfs_disc_t *disc = NULL;

	/* Try to open game disc */
	disc = wbfs_open_disc(hdd, discid);
	if (disc) {
		/* Close disc */
		wbfs_close_disc(disc);

		return 1;
	}

	return 0;
}
Exemplo n.º 7
0
int op_add_iso(char *filename, void (*update)(int, int))
{
  FILE *f;
  wbfs_disc_t *disc;
  char code[7];
  int ret;

  cancel_wbfs_op = 0;
  if (! update)
    update = progress_update;

  /* open ISO */
  f = fopen(filename, "r");
  if (f == NULL) {
    show_error("Error Adding ISO", "Can't open ISO file '%s'", filename);
    return 1;
  }
  if (fread(code, 1, 6, f) != 6) {
    fclose(f);
    show_error("Error Adding ISO", "Can't read disc ID from file '%s'.", filename);
    return 1;
  }
  code[6] = '\0';

  /* check if disc is already there */
  disc = wbfs_open_disc(app_state.wbfs, (u8 *) code);
  if (disc != NULL) {
    wbfs_close_disc(disc);
    fclose(f);
    show_error("Error Adding ISO", "The disc is already in the WBFS partition.");
    return 1;
  }

  /* add disc */
  ret = wbfs_add_disc(app_state.wbfs, read_wii_file, (void *) f, update, ONLY_GAME_PARTITION, 0, NULL);
  
  fclose(f);
  return ret;
}