Example #1
0
static int ethNeedsUpdate(void) {
	int result;

	result = 0;

	if (ethULSizePrev == -2)
		result = 1;

	if (gNetworkStartup == 0) {
		iox_stat_t stat;
		char path[256];

		sprintf(path, "%sCD", ethPrefix);
		if (fileXioGetStat(path, &stat) != 0)
			memset(stat.mtime, 0, 8);
		if (memcmp(ethModifiedCDPrev, stat.mtime, 8)) {
			memcpy(ethModifiedCDPrev, stat.mtime, 8);
			result = 1;
		}

		sprintf(path, "%sDVD", ethPrefix);
		if (fileXioGetStat(path, &stat) != 0)
			memset(stat.mtime, 0, 8);
		if (memcmp(ethModifiedDVDPrev, stat.mtime, 8)) {
			memcpy(ethModifiedDVDPrev, stat.mtime, 8);
			result = 1;
		}

		if (!sbIsSameSize(ethPrefix, ethULSizePrev))
			result = 1;
	}

	return result;
}
datetime_t FileDateTime(nodecontext *p,const tchar_t* Path)
{
    iox_stat_t Stat;
    if (fileXioGetStat(Path,&Stat)==0)
        return PS2ToDateTime(Stat.mtime);
	return INVALID_DATETIME_T;
}
Example #3
0
void Ps2FilesystemNode::doverify(void) {
	PS2Device medium;
	int fd;

	if (_verified)
		return;

	_verified = true;

	dbg_printf(" verify: %s -> ", _path.c_str());

#if 0
	if (_path.empty()) {
		dbg_printf("PlayStation 2 Root !\n");
		_verified = true;
		return;
	}

	if (_path.lastChar() == ':') {
		dbg_printf("Dev: %s\n", _path.c_str());
		_verified = true;
		return;
	}
#endif

	if (_path[3] != ':' && _path[4] != ':') {
		dbg_printf("relative path !\n");
		_isHere = false;
		_isDirectory = false;
		return;
	}

	medium = _getDev(_path);
	if (medium == ERR_DEV) {
		_isHere = false;
		_isDirectory = false;
		return;
	}

	switch (medium) {
#if 0
	case HD_DEV: /*stat*/
	case USB_DEV:
		iox_stat_t stat;

		fileXioGetStat(_path.c_str(), &stat);
		fileXioWaitAsync(FXIO_WAIT, &fd);

		if (!fd) {
			dbg_printf("  yes [stat]\n");
			return true;
		}
	break;
#endif

	case CD_DEV: /*no stat*/
	case HD_DEV:
	case USB_DEV:
	case HOST_DEV:
	case MC_DEV:
#if 1
	fd = fio.open(_path.c_str(), O_RDONLY);

	dbg_printf("_path = %s -- fio.open -> %d\n", _path.c_str(), fd);

	if (fd >=0) {
		fio.close(fd);
		dbg_printf("  yes [open]\n");
		_isHere = true;
		if (medium==MC_DEV && _path.lastChar()=='/')
			_isDirectory = true;
		else
			_isDirectory = false;
		return;
	}

	fd = fio.dopen(_path.c_str());
	if (fd >=0) {
		fio.dclose(fd);
		dbg_printf("  yes [dopen]\n");
		_isHere = true;
		_isDirectory = true;
		return;
	}

#else
	fileXioOpen(_path.c_str(), O_RDONLY, DEFAULT_MODE);
	fileXioWaitAsync(FXIO_WAIT, &fd);
	if (fd>=0) {
		fileXioClose(fd);
		fileXioWaitAsync(FXIO_WAIT, &fd);
		return true;
	}

	fileXioDopen(_path.c_str());
	fileXioWaitAsync(FXIO_WAIT, &fd);
	if (fd>=0) {
		fileXioDclose(fd);
		fileXioWaitAsync(FXIO_WAIT, &fd);
		return true;
	}
#endif
	break;
	case ERR_DEV:
		_isHere = false;
		_isDirectory = false;
	break;
	}

	_isHere = false;
	_isDirectory = false;

	dbg_printf("  no\n");
	return;
}
Example #4
0
void list_mountable_devices(char *device, list_t *list)
{

	int i,n = 0;

	iox_stat_t stat;

	char mc_path[6] = "mc0:";
	char mass_device[8] = "mass0:";

	add_reg_entry(list->entries,"..",n++);

	if (!strcmp(device,"mc"))
	{
		for (i = 0; i < 2; i++)
		{
			mc_path[2] = '0' + i;
			if(!fileXioGetStat(mc_path,&stat))
			{
				add_dir_entry(list->entries,mc_path,n++);
			}
		}

		list->num = n;

	}

	if (!strcmp(device,"mass"))
	{
		for(i=0; i < 10; i++)
		{

			mass_device[4] = '0'+i;

			if(!(fileXioGetStat(mass_device, &stat) < 0))
			{
				add_dir_entry(list->entries,mass_device,n++);
			}
		}

	// Older versions of the module only support "mass:"
		if (!n)
		{
			if (!(fileXioGetStat("mass:",&stat) < 0))
			{
				add_dir_entry(list->entries,"mass:",n++);
			}

		}

		list->num = n;

	}

	if (!strcmp(device,"hdd"))
	{

		// Checking for "hdd0:" doesn't work, maybe since it's a block device
		//if (!(fileXioGetStat("hdd0:",&stat) < 0))
		{
			list_partitions(list);
		}
	}

	if (!strcmp(device,"cdfs"))
	{
		//if(!(fileXioGetStat("cdfs:",&stat) < 0))
		{
			add_dir_entry(list->entries,"cdfs:", n++);
		}

		CDVD_FlushCache();
		refresh_cdfs();

		list->num = n;

	}
	else
	{
		CDVD_Stop();
	}

}