Exemplo n.º 1
0
int FileRead( FHANDLE handle, void *buffer, int size )
{
	int ret = 0;

	if( handle.dt == DT_CD ) {
		ret = fioRead( handle.fh, buffer, size );
	}
	else if( handle.dt == DT_HDD ) {
		ret = fileXioRead( handle.fh, buffer, size );
	}
	else if( handle.dt == DT_MC ) {
		ret = fioRead( handle.fh, buffer, size );
	}
	else if( handle.dt == DT_USB ) {
		ret = fioRead( handle.fh, buffer, size );
	}
	else if( handle.dt == DT_HOST ) {
		ret = fioRead( handle.fh, buffer, size );
	}
	else if( handle.dt == DT_SMB_SHARE ) {
		ret = smbc_read( handle.fh, buffer, size );
	}

	return ret;
}
Exemplo n.º 2
0
void AsyncFio::read(int fd, void *dest, unsigned int len) {
	WaitSema(_ioSema);
	checkSync();
	assert(fd < MAX_HANDLES);
	_runningOp = _ioSlots + fd;
	fileXioRead(fd, (unsigned char*)dest, len);
	SignalSema(_ioSema);
}
Exemplo n.º 3
0
/****************************************************************************
 * Universal file reading function.  Returns the amount of bytes read.		*
 ****************************************************************************/
int ReadFile(int handle, unsigned char *buffer, int size, int media)
{
	int sr =0;
//	printf ("ReadFile(%d, %p, %d, %d)\n", handle, buffer, size, media);
	switch (media)
	{
	case 0:
		{
			sr = fileXioRead(handle, buffer, size);
			break;
		}
	case 1:
		{
			sr = fioRead(handle, buffer, size);
			break;
		}
	case 2:
		{
			//sr = fioRead(handle, buffer, size);
			sr = fileXioRead(handle, buffer, size);
			break;
		}
	case 3:
		{
			//sr = fioRead(handle, buffer, size);
			sr = fileXioRead(handle, buffer, size);
			break;
		}
	case 4:
		{
			sr = fioRead(handle, buffer, size);
			break;
		}
	case 5:
		{
			sr = fileXioRead(handle, buffer, size);
			break;
		}
	}
	return sr;
}
Exemplo n.º 4
0
static err_t Read(filestream* p,void* Data,size_t Size,size_t* Readed)
{
    err_t Err;
    int n;

    n = fileXioRead(p->fd, Data, (unsigned int)Size);
    if (n<0)
    {
        n=0;
        Err = ERR_READ;
    }
    else
        Err = ((size_t)n != Size) ? ERR_END_OF_FILE:ERR_NONE;

    if (Readed)
        *Readed = n;
    return Err;
}
Exemplo n.º 5
0
static int ethPrepareMcemu(base_game_info_t* game) {
	char vmc[2][32];
	char vmc_path[255];
	u32 vmc_size;
	int i, j, fd, size_mcemu_irx = 0;
	smb_vmc_infos_t smb_vmc_infos;
	vmc_superblock_t vmc_superblock;

	configGetVMC(game->startup, vmc[0], ETH_MODE, 0);
	configGetVMC(game->startup, vmc[1], ETH_MODE, 1);

	for(i=0; i<2; i++) {
		if(!vmc[i][0]) // skip if empty
			continue;

		memset(&smb_vmc_infos, 0, sizeof(smb_vmc_infos_t));
		memset(&vmc_superblock, 0, sizeof(vmc_superblock_t));

		snprintf(vmc_path, 255, "%s\\VMC\\%s.bin", ethPrefix, vmc[i]);

		fd = fileXioOpen(vmc_path, O_RDONLY, 0666);
		if (fd >= 0) {
			size_mcemu_irx = -1;
			LOG("%s open\n", vmc_path);

			vmc_size = fileXioLseek(fd, 0, SEEK_END);
			fileXioLseek(fd, 0, SEEK_SET);
			fileXioRead(fd, (void*)&vmc_superblock, sizeof(vmc_superblock_t));

			LOG("File size : 0x%X\n", vmc_size);
			LOG("Magic     : %s\n", vmc_superblock.magic);
			LOG("Card type : %d\n", vmc_superblock.mc_type);

			if(!strncmp(vmc_superblock.magic, "Sony PS2 Memory Card Format", 27) && vmc_superblock.mc_type == 0x2) {
				smb_vmc_infos.flags            = vmc_superblock.mc_flag & 0xFF;
				smb_vmc_infos.flags           |= 0x100;
				smb_vmc_infos.specs.page_size  = vmc_superblock.page_size;                                       
				smb_vmc_infos.specs.block_size = vmc_superblock.pages_per_block;                                 
				smb_vmc_infos.specs.card_size  = vmc_superblock.pages_per_cluster * vmc_superblock.clusters_per_card;

				LOG("flags            : 0x%X\n", smb_vmc_infos.flags           );
				LOG("specs.page_size  : 0x%X\n", smb_vmc_infos.specs.page_size );
				LOG("specs.block_size : 0x%X\n", smb_vmc_infos.specs.block_size);
				LOG("specs.card_size  : 0x%X\n", smb_vmc_infos.specs.card_size );

				if(vmc_size == smb_vmc_infos.specs.card_size * smb_vmc_infos.specs.page_size) {
					smb_vmc_infos.active = 1;
					smb_vmc_infos.fid    = 0xFFFF;
					snprintf(vmc_path, 255, "VMC\\%s.bin", vmc[i]);
					strncpy(smb_vmc_infos.fname, vmc_path, 32); // maybe a too small size here ...

					LOG("%s is a valid Vmc file\n", smb_vmc_infos.fname );
				}
			}
			fileXioClose(fd);
		}
		for (j=0; j<size_smb_mcemu_irx; j++) {
			if (((u32*)&smb_mcemu_irx)[j] == (0xC0DEFAC0 + i)) {
				if(smb_vmc_infos.active)
					size_mcemu_irx = size_smb_mcemu_irx;
				memcpy(&((u32*)&smb_mcemu_irx)[j], &smb_vmc_infos, sizeof(smb_vmc_infos_t));
				break;
			}
		}
	}
	return size_mcemu_irx;
}