u8 *load_file_from_ISO(const char *iso, char *name, int *size) { int ret; u32 lba; u8 *buf; ret = isoOpen(iso); if (ret < 0) { return NULL; } ret = isoGetFileInfo(name, (u32*)size, &lba); if (ret < 0) { isoClose(); return NULL; } buf = malloc(*size); if (buf == NULL) { isoClose(); return NULL; } ret = isoRead(buf, lba, 0, *size); if (ret < 0) { isoClose(); return NULL; } isoClose(); return buf; }
void Decompress(char *filename) { struct stat buf; char file[256]; u8 cdbuff[10*2352]; u32 lsn; isoFile *src; isoFile *dst; int ret = 0; src = isoOpen(filename); if (src == NULL) return; strcpy(file, filename); if (src->flags & ISOFLAGS_Z) file[strlen(file) - 2] = 0; else if (src->flags & ISOFLAGS_Z2) file[strlen(file) - 3] = 0; else if (src->flags & ISOFLAGS_BZ2) file[strlen(file) - 3] = 0; else { printf("%s is not a compressed image\n", filename); return; } if (stat(file, &buf) != -1) { char str[256]; sprintf(str, "'%s' already exists", file); isoClose(src); return; } dst = isoCreate(file, 0); if (dst == NULL) return; isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks); for (lsn = 0; lsn < src->blocks; lsn++) { printf("block %d ", lsn); putchar(13); fflush(stdout); ret = isoReadBlock(src, cdbuff, lsn); if (ret == -1) break; ret = isoWriteBlock(dst, cdbuff, lsn); if (ret == -1) break; } isoClose(src); isoClose(dst); if (ret == -1) printf("Error decompressing iso image\n"); else printf("Iso image decompressed OK\n"); }
static int has_prometheus_module(VirtualPBP *vpbp) { int ret; u32 size, lba; ret = isoOpen(vpbp->name); if (ret < 0) { return 0; } ret = isoGetFileInfo("/PSP_GAME/SYSDIR/EBOOT.OLD", &size, &lba); ret = (ret >= 0) ? 1 : 0; isoClose(); return ret; }
SceUID vpbp_open(const char * file, int flags, SceMode mode) { int ret; VirtualPBP *vpbp; lock(); if (flags & (PSP_O_WRONLY | PSP_O_TRUNC | PSP_O_CREAT) || !(flags & PSP_O_RDONLY)) { printk("%s: bad flags 0x%08X\n", __func__, flags); unlock(); return -6; } vpbp = get_vpbp_by_path(file); if (vpbp == NULL) { printk("%s: Unknown file %s in vpbp list\n", __func__, file); unlock(); return -12; } if (vpbp->enabled) { vpbp->file_pointer = 0; ret = isoOpen(vpbp->name); if (ret < 0) { printk("%s: isoOpen -> %d\n", __func__, ret); unlock(); return -29; } unlock(); return MAGIC_VPBP_FD+(vpbp-&g_vpbps[0]); } unlock(); return -26; }
int vshDetectDiscType(const char *path) { int result, ret; u32 k1; result = -1; k1 = pspSdkSetK1(0); ret = isoOpen(path); if (ret < 0) { pspSdkSetK1(k1); return result; } result = 0; if(has_file("/PSP_GAME/SYSDIR/EBOOT.BIN")) { result |= PSP_UMD_TYPE_GAME; } if(has_file("/UMD_VIDEO/PLAYLIST.UMD")) { result |= PSP_UMD_TYPE_VIDEO; } if(has_file("/UMD_AUDIO/PLAYLIST.UMD")) { result |= PSP_UMD_TYPE_AUDIO; } if(result == 0) { result = -2; } isoClose(); pspSdkSetK1(k1); return result; }
static int build_vpbp(VirtualPBP *vpbp) { int ret, i; u32 off; printk("Need to build vpbp %s\n", vpbp->name); memset(vpbp->header, 0, sizeof(vpbp->header)); memset(vpbp->sects, 0, sizeof(vpbp->sects)); vpbp->enabled = 1; vpbp->file_pointer = 0; vpbp->header[0] = 0x50425000; // PBP magic vpbp->header[1] = 0x10000; // version // fill vpbp offsets off = 0x28; ret = isoOpen(vpbp->name); if (ret < 0) { printk("%s: isoOpen -> %d\n", __func__, ret); ret = add_cache(vpbp); return ret; } for(i=0; i<NELEMS(pbp_entries); ++i) { vpbp->header[i+2] = off; if (pbp_entries[i].enabled) { PBPSection *sec = &vpbp->sects[i]; ret = isoGetFileInfo(pbp_entries[i].name, &sec->size, &sec->lba); if (ret < 0) { if (i == 0) { // no PARAM.SFO? // then it's a bad ISO isoClose(); return -36; } else { continue; } } if (i == 0) { off += sizeof(virtualsfo); } else { off += sec->size; } } } vpbp->pbp_total_size = vpbp->header[9]; get_iso_file_size(vpbp->name, &vpbp->iso_total_size); ret = add_cache(vpbp); printk("%s: add_cache -> %d\n", __func__, ret); isoClose(); return ret; }
void Compress(char *filename, int mode) { struct stat buf; u32 lsn; u8 cdbuff[1024*16]; char Zfile[256]; int ret = 0; isoFile *src; isoFile *dst; if (mode == 1) { sprintf(Zfile, "%s.Z2", filename); } else { sprintf(Zfile, "%s.BZ2", filename); } if (stat(Zfile, &buf) != -1) { printf("'%s' already exists\n", Zfile); return; /* sprintf(str, "'%s' already exists, overwrite?", Zfile); if (MessageBox(hDlg, str, "Question", MB_YESNO) != IDYES) { return; }*/ } printf("src %s; dst %s\n", filename, Zfile); src = isoOpen(filename); if (src == NULL) return; if (mode == 1) { dst = isoCreate(Zfile, ISOFLAGS_Z2); } else { dst = isoCreate(Zfile, ISOFLAGS_BZ2); } isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks); if (dst == NULL) return; for (lsn = 0; lsn < src->blocks; lsn++) { printf("block %d ", lsn); putchar(13); fflush(stdout); ret = isoReadBlock(src, cdbuff, lsn); if (ret == -1) break; ret = isoWriteBlock(dst, cdbuff, lsn); if (ret == -1) break; } isoClose(src); isoClose(dst); if (ret == -1) { printf("Error compressing iso image\n"); } else { printf("Iso image compressed OK\n"); } }