int IoOpen_new( PspIoDrvFileArg * arg, char * file, int flags, SceMode mode ) { PspIoDrvArg * drv = arg->drv; if( ctf_handler && arg->fs_num == 0 ) { ctf_handler[handler_count].num = inCtf( file ); if ( ctf_handler[handler_count].num >= 0 ) { log( "replace %s\n", file ); arg->drv = ms_drv; int ret = fatms_drv->funcs->IoOpen( arg, theme_file, flags, mode); if ( ret < 0 ) { arg->drv = drv; } else { ctf_handler[handler_count].offset = fatms_drv->funcs->IoLseek( arg, ctf_header[ctf_handler[handler_count].num].start, PSP_SEEK_SET ); ctf_handler[handler_count].arg = arg->arg; handler_count ++; if ( handler_count % 32 == 0 ) { CtfHandler * tmp = sceKernelAllocHeapMemory( mem_id, sizeof( CtfHandler ) * ( handler_count + 32 ) ); memcpy( tmp, ctf_handler, sizeof( CtfHandler ) * handler_count ); sceKernelFreeHeapMemory( mem_id, ctf_handler ); ctf_handler = tmp; } arg->drv = drv; return ret; } } } int ret = IoOpen( arg, file, flags, mode ); if ( strcmp( file, "/vsh/theme/custom_theme.dat" ) == 0 && flags == ( PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC ) ) { t_record = arg->arg; log( "open %s flags %08x\ntheme file selected: %s\n", file, flags, selected_theme_file ); } return ret; }
FILE *IoReader(string filename) { return IoOpen(filename, "r"); }