本文整理汇总了C++中sceIoRead函数的典型用法代码示例。如果您正苦于以下问题:C++ sceIoRead函数的具体用法?C++ sceIoRead怎么用?C++ sceIoRead使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sceIoRead函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseDiff
int parseDiff( const char * file, tSceModule * mod )
{
int off = inCtf( file );
if ( off < 0 )
{
log( "there's no patch for %s\n", file );
return 0;
}
int ctf = sceIoOpen( cxmb_theme_file, PSP_O_RDONLY, 0644 );
if ( ctf < 0 )
{
log( "no ctf file found!\n" );
return -1;
}
sceIoLseek( ctf, ctf_header[off].start, PSP_SEEK_SET );
log( "patch %s!\nstart: %08x\nsize: %08x\n", file, ctf_header[off].start, ctf_header[off].size );
unsigned int attr[2];
int i = 0;
while( i < ctf_header[off].size )
{
sceIoRead( ctf, attr, 8 );
sceIoRead( ctf, ( void * )( mod->text_addr + attr[0] ), attr[1] );
i ++;
}
sceIoClose( ctf );
sceKernelIcacheInvalidateAll();
sceKernelDcacheWritebackInvalidateAll();
log( "%s patched!\n", file );
return 0;
}
示例2: neogeo_init
static int neogeo_init(void)
{
SceUID fd;
char path[MAX_PATH];
sprintf(path, "%smemcard/%s.bin", launchDir, game_name);
if ((fd = sceIoOpen(path, PSP_O_RDONLY, 0777)) >= 0)
{
sceIoRead(fd, neogeo_memcard, 0x800);
sceIoClose(fd);
}
sprintf(path, "%snvram/%s.nv", launchDir, game_name);
if ((fd = sceIoOpen(path, PSP_O_RDONLY, 0777)) >= 0)
{
sceIoRead(fd, neogeo_sram16, 0x2000);
sceIoClose(fd);
swab(neogeo_sram16, neogeo_sram16, 0x2000);
}
neogeo_driver_init();
neogeo_video_init();
msg_printf(TEXT(DONE2));
return 1;
}
示例3: sceIoRead
frame_cfg_t *frame_factory_read_cfg(SceUID fd)
{
int bytes = 0;
int cfg_size = 0;
frame_cfg_t *cfg = NULL;
if (fd == -1) {
goto error;
}
bytes = sceIoRead(fd, &cfg_size, sizeof(cfg_size));
if (bytes != sizeof(cfg_size)) {
printf("can't read file size\n");
goto error;
}
//printf("cfg size %d\n", cfg_size);
cfg = (frame_cfg_t *)malloc(cfg_size);
if (cfg == NULL) {
printf("not enough mem!\n");
goto error;
}
cfg->size = cfg_size;
bytes = sceIoRead(fd, (void*)cfg+sizeof(cfg_size), cfg_size-sizeof(cfg_size));
if (bytes != cfg_size-sizeof(cfg_size)) {
printf("size check fail %d/%d\n", cfg_size, bytes);
goto error;
}
return cfg;
error:
if (cfg != NULL) {
free(cfg);
}
return NULL;
}
示例4: mhp3_read
int mhp3_read(SceUID fd, void *data, SceSize size) {
u32 k1;
int res;
u32 cur;
SceOff pos;
SceSize offset;
if (fd == datafd) {
pos = sceIoLseek(fd, 0, PSP_SEEK_CUR);
cur = 0;
offset = data_start;
while (cur < patch_count) {
if (pos < patch_offset[cur] + patch_size[cur] && pos + size > patch_offset[cur]) {
k1 = pspSdkSetK1(0);
reopen_translation();
sceIoLseek(transfd, offset + (pos - patch_offset[cur]), PSP_SEEK_SET);
res = sceIoRead(transfd, data, size);
if (res != (int) size) {
kprintf("failed to read translation data\n");
}
pspSdkSetK1(k1);
sceIoLseek(fd, size, PSP_SEEK_CUR);
return res;
}
offset += patch_size[cur];
cur++;
}
} else {
res = read_install(fd, data, size);
return res;
}
res = sceIoRead(fd, data, size);
return res;
}
示例5: fill_tables
int fill_tables(SceUID fd) {
if (fd < 0)
return -1;
sceIoLseek(fd, 0, PSP_SEEK_SET);
sceIoRead(fd, &patch_count, 4);
// max permitted: 6KiB
if (patch_count > 6144) {
patch_count = 6144;
}
kprintf("Allocating %i bytes\n", patch_count * 4 * 3);
memid = sceKernelAllocPartitionMemory(PSP_MEMORY_PARTITION_KERNEL, "mhp3tbl", PSP_SMEM_High, patch_count * 4 * 3, NULL);
if (memid < 0) {
kprintf("Mamory alloc failed\n");
return -1;
}
patch_offset = sceKernelGetBlockHeadAddr(memid);
kprintf("patch_offset addr: %08X\n", (u32)patch_offset);
patch_size = &patch_offset[patch_count];
kprintf("patch_size addr: %08X\n", (u32)patch_size);
for (u32 i = 0; i < patch_count; i++) {
sceIoRead(fd, &patch_offset[i], 4);
sceIoRead(fd, &patch_size[i], 4);
}
data_start = ((patch_count + 1) * 8);
if (data_start % 16 > 0) {
data_start += 16 - (data_start % 16);
}
return 0;
}
示例6: checkIo
void checkIo(int doDispatch) {
char temp[128];
SceUID fd = sceIoOpen("dispatch.prx", PSP_O_RDONLY, 0777);
dispatchCheckpoint("sceIoOpen: %08x", fd >= 0 ? 1 : fd);
dispatchCheckpoint("sceIoRead: %08x", sceIoRead(fd, temp, sizeof(temp)));
dispatchCheckpoint("sceIoClose: %08x", sceIoClose(fd));
int state;
if (doDispatch) {
++ignoreResched;
state = sceKernelSuspendDispatchThread();
dispatchCheckpoint("sceKernelSuspendDispatchThread: %08x", state);
}
fd = sceIoOpen("dispatch.prx", PSP_O_RDONLY, 0777);
dispatchCheckpoint("sceIoOpen: %08x", fd >= 0 ? 1 : fd);
dispatchCheckpoint("sceIoRead: %08x", sceIoRead(fd, temp, sizeof(temp)));
dispatchCheckpoint("sceIoClose: %08x", sceIoClose(fd));
if (doDispatch) {
dispatchCheckpoint("sceKernelResumeDispatchThread: %08x", sceKernelResumeDispatchThread(state));
--ignoreResched;
}
SceInt64 res = -1;
int result = -1;
fd = sceIoOpenAsync("dispatch.prx", PSP_O_RDONLY, 0777);
dispatchCheckpoint("sceIoOpenAsync: %08x", fd >= 0 ? 1 : fd);
if (doDispatch) {
++ignoreResched;
state = sceKernelSuspendDispatchThread();
dispatchCheckpoint("sceKernelSuspendDispatchThread: %08x", state);
}
result = sceIoPollAsync(fd, &res);
dispatchCheckpoint("sceIoPollAsync: %08x / %016llx", result, res >= 0 ? 1LL : res);
result = sceIoGetAsyncStat(fd, 1, &res);
dispatchCheckpoint("sceIoGetAsyncStat: %08x / %016llx", result, res >= 0 ? 1LL : res);
result = sceIoGetAsyncStat(fd, 0, &res);
dispatchCheckpoint("sceIoGetAsyncStat: %08x / %016llx", result, res >= 0 ? 1LL : res);
result = sceIoWaitAsync(fd, &res);
dispatchCheckpoint("sceIoWaitAsync: %08x / %016llx", result, res >= 0 ? 1LL : res);
if (doDispatch) {
dispatchCheckpoint("sceKernelResumeDispatchThread: %08x", sceKernelResumeDispatchThread(state));
--ignoreResched;
}
result = sceIoWaitAsync(fd, &res);
dispatchCheckpoint("sceIoWaitAsync: %08x / %016llx", result, res >= 0 ? 1LL : res);
if (doDispatch) {
++ignoreResched;
state = sceKernelSuspendDispatchThread();
dispatchCheckpoint("sceKernelSuspendDispatchThread: %08x", state);
}
dispatchCheckpoint("sceIoRead: %08x", sceIoRead(fd, temp, sizeof(temp)));
dispatchCheckpoint("sceIoWrite: %08x", sceIoWrite(1, "Hello.", sizeof("Hello.")));
if (doDispatch) {
dispatchCheckpoint("sceKernelResumeDispatchThread: %08x", sceKernelResumeDispatchThread(state));
--ignoreResched;
}
dispatchCheckpoint("sceIoCloseAsync: %08x", sceIoCloseAsync(fd));
result = sceIoWaitAsync(fd, &res);
dispatchCheckpoint("sceIoWaitAsync: %08x / %016llx", result, res);
}
示例7: colorconfig_read
int colorconfig_read(ColorConfig* prConfig, SceUID fd) {
if (prConfig == NULL) {
return COLORCONFIG_NULLPTR;
}
sceIoRead(fd, &prConfig->background, sizeof(u32));
sceIoRead(fd, &prConfig->text, sizeof(u32));
return COLORCONFIG_SUCCESS;
}
示例8: sceIoOpen
void PBPParse::Parse(const char *file){
fid = sceIoOpen(file, PSP_O_RDONLY, 0777);
sceIoMkdir("ms0:/TMP", 0777);
if (fid >= 0)
{
if (sceIoRead(fid, &header, sizeof(PBPHeader)) == sizeof(PBPHeader)){
char *temp = (char*)malloc(header.icon0 - header.sfo);
sceIoLseek(fid, header.sfo, PSP_SEEK_SET);
sceIoRead(fid, temp, header.icon0 - header.sfo);
SceUID sfoFile = sceIoOpen("ms0:/TMP/PARAM.SFO", PSP_O_CREAT | PSP_O_WRONLY, 0777);
sceIoWrite(sfoFile, temp, header.icon0 - header.sfo);
sceIoClose(sfoFile);
free(temp);
sfo.Parse("ms0:/TMP/PARAM.SFO");
temp = (char*)malloc(header.icon1 - header.icon0);
sceIoLseek(fid, header.icon0, PSP_SEEK_SET);
sceIoRead(fid, temp, header.icon1 - header.icon0);
SceUID icoFile = sceIoOpen("ms0:/TMP/ICON0.PNG", PSP_O_CREAT | PSP_O_WRONLY, 0777);
sceIoWrite(icoFile, temp, header.icon1 - header.icon0);
sceIoClose(icoFile);
if (header.icon1 - header.icon0 > 0){
OSL_IMAGE *ico = oslLoadImageFilePNG("ms0:/TMP/ICON0.PNG", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_5650);
icon = oslScaleImageCreate(ico, OSL_IN_RAM, 64, 64, OSL_PF_5650);
oslDeleteImage(ico);
oslWriteImageFilePNG(icon, "ms0:/TMP/ICON0.PNG", 0);
}
else{
icon = oslCreateImageCopy(defaultUNKN, OSL_IN_RAM);
}
free(temp);
temp = (char*)malloc(header.snd - header.pic1);
sceIoLseek(fid, header.pic1, PSP_SEEK_SET);
sceIoRead(fid, temp, header.snd - header.pic1);
SceUID picFile = sceIoOpen("ms0:/TMP/PIC1.PNG", PSP_O_CREAT | PSP_O_WRONLY, 0777);
sceIoWrite(picFile, temp, header.snd - header.pic1);
sceIoClose(picFile);
if (header.snd - header.pic1 > 0){
pic = oslLoadImageFilePNG("ms0:/TMP/PIC1.PNG", OSL_IN_RAM, OSL_PF_8888);
OSL_IMAGE *tmpPic = oslScaleImageCreate(pic, OSL_IN_RAM, 128, 128, OSL_PF_8888);
oslUnswizzleImage(tmpPic);
oslWriteImageFilePNG(tmpPic, "ms0:/TMP/PIC1SC.PNG", 0);
oslDeleteImage(tmpPic);
oslDeleteImage(pic); //Get rid of the pic file for now, we don't need it
}
free(temp);
sceIoClose(fid);
}
}
}
示例9: MP3ME_SeekNextFrameMP3
//Seek next valid frame
//NOTE: this function comes from Music prx 0.55 source
// all credits goes to joek2100.
int MP3ME_SeekNextFrameMP3(SceUID fd)
{
int offset = 0;
unsigned char buf[1024];
unsigned char *pBuffer;
int i;
int size = 0;
offset = sceIoLseek32(fd, 0, PSP_SEEK_CUR);
sceIoRead(fd, buf, sizeof(buf));
if (!strncmp((char*)buf, "ID3", 3) || !strncmp((char*)buf, "ea3", 3)) //skip past id3v2 header, which can cause a false sync to be found
{
//get the real size from the syncsafe int
size = buf[6];
size = (size<<7) | buf[7];
size = (size<<7) | buf[8];
size = (size<<7) | buf[9];
size += 10;
if (buf[5] & 0x10) //has footer
size += 10;
}
sceIoLseek32(fd, offset, PSP_SEEK_SET); //now seek for a sync
while(1)
{
offset = sceIoLseek32(fd, 0, PSP_SEEK_CUR);
size = sceIoRead(fd, buf, sizeof(buf));
if (size <= 2)//at end of file
return -1;
if (!strncmp((char*)buf, "EA3", 3))//oma mp3 files have non-safe ints in the EA3 header
{
sceIoLseek32(fd, (buf[4]<<8)+buf[5], PSP_SEEK_CUR);
continue;
}
pBuffer = buf;
for( i = 0; i < size; i++)
{
//if this is a valid frame sync (0xe0 is for mpeg version 2.5,2+1)
if ( (pBuffer[i] == 0xff) && ((pBuffer[i+1] & 0xE0) == 0xE0))
{
offset += i;
sceIoLseek32(fd, offset, PSP_SEEK_SET);
return offset;
}
}
//go back two bytes to catch any syncs that on the boundary
sceIoLseek32(fd, -2, PSP_SEEK_CUR);
}
}
示例10: loadTheme
void loadTheme()
{
int i, bytesRead;
SceUID fp;
fp = sceIoOpen("ms0:/lockdown.thm", PSP_O_RDONLY, 0777);
if (fp < 0)
{
fp = sceIoOpen("flash0:/lockdown.thm", PSP_O_RDONLY, 0777);
if (fp < 0)
{
printTextScreen(0, 0, "Error loading flash0:/lockdown.thm.", RGB(255, 0, 0));
printTextScreen(0, 8, "Place theme at ms0:/lockdown.thm to load from memory stick.", RGB(255, 0, 0));
sceDisplayWaitVblankStart();
flipScreen();
sceKernelSleepThread();
}
}
for (i = 0; i < NUMFILES; i++)
{
bytesRead = sceIoRead(fp, &images[i].hdr, sizeof(imagehdr));
if (bytesRead != sizeof(imagehdr))
{
printTextScreen(0, 0, "Unexpected end of header.", RGB(255, 0, 0));
sceDisplayWaitVblankStart();
flipScreen();
sceKernelSleepThread();
}
images[i].blockid = sceKernelAllocPartitionMemory(2, "block", 0, (sizeof(unsigned char) * images[i].hdr.size), NULL);
if (images[i].blockid < 0)
{
printTextScreen(0, 0, "Memory allocation error.", RGB(255, 0, 0));
sceDisplayWaitVblankStart();
flipScreen();
sceKernelSleepThread();
}
images[i].data = (unsigned char*) sceKernelGetBlockHeadAddr(images[i].blockid);
bytesRead = sceIoRead(fp, images[i].data, images[i].hdr.size);
if (bytesRead != images[i].hdr.size)
{
printTextScreen(0, 0, "Unexpected end of data.", RGB(255, 0, 0));
sceDisplayWaitVblankStart();
flipScreen();
sceKernelSleepThread();
}
}
sceIoClose(fp);
}
示例11: compare_file_buffer
int compare_file_buffer(const char *path, void *file_buf, int size)
{
SceUID fd = -1;
int ret;
SceIoStat srcstat;
ret = sceIoGetstat(path, &srcstat);
if (ret != 0) {
goto not_equal;
}
if (srcstat.st_size != size) {
goto not_equal;
}
ret = sceIoOpen(path, PSP_O_RDONLY, 0777);
if (ret < 0) {
goto not_equal;
}
fd = ret;
ret = sizeof(g_buf);
ret = sceIoRead(fd, g_buf, ret);
while (ret > 0) {
if (memcmp(g_buf, file_buf, ret)) {
goto not_equal;
}
file_buf += ret;
ret = sceIoRead(fd, g_buf, ret);
}
if (ret < 0) {
goto not_equal;
}
sceIoClose(fd);
return 0;
not_equal:
if (fd >= 0)
sceIoClose(fd);
return 1;
}
示例12: get_icon0_status
static int get_icon0_status(void)
{
u32 icon0_offset = 0;
int result = ICON0_MISSING;
SceUID fd = -1;;
const char *filename;
u8 p[40 + 64], *header;
header = (u8*)((((u32)p) & ~(64-1)) + 64);
filename = sceKernelInitFileName();
if(filename == NULL) {
goto exit;
}
fd = sceIoOpen(filename, PSP_O_RDONLY, 0777);
if(fd < 0) {
printk("%s: sceIoOpen %s -> 0x%08X\n", __func__, filename, fd);
goto exit;
}
sceIoRead(fd, header, 40);
icon0_offset = *(u32*)(header+0x0c);
sceIoLseek32(fd, icon0_offset, PSP_SEEK_SET);
sceIoRead(fd, header, 40);
if(*(u32*)(header+4) == 0xA1A0A0D) {
if ( *(u32*)(header+0xc) == 0x52444849 && // IHDR
*(u32*)(header+0x10) == 0x50000000 && //
*(u32*)(header+0x14) == *(u32*)(header+0x10)
) {
result = ICON0_OK;
} else {
result = ICON0_CORRUPTED;
}
} else {
result = ICON0_MISSING;
}
printk("%s: PNG file status -> %d\n", __func__, result);
exit:
if(fd >= 0) {
sceIoClose(fd);
}
return result;
}
示例13: copy_file
int copy_file(const char *src, const char *dst)
{
SceUID fd = -1, fdw = -1;
int ret;
ret = sceIoOpen(src, PSP_O_RDONLY, 0777);
if (ret < 0) {
goto error;
}
fd = ret;
ret = sceIoOpen(dst, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
if (ret < 0) {
goto error;
}
fdw = ret;
ret = sizeof(g_buf);
ret = sceIoRead(fd, g_buf, ret);
while (ret > 0) {
ret = sceIoWrite(fdw, g_buf, ret);
if (ret < 0) {
goto error;
}
ret = sceIoRead(fd, g_buf, ret);
}
if (ret < 0) {
goto error;
}
sceIoClose(fd);
sceIoClose(fdw);
return 0;
error:
sceIoClose(fd);
sceIoClose(fdw);
return ret;
}
示例14: sceIoOpen
pgeObj *pgeObjLoad(const char *filename)
{
int fd = sceIoOpen(filename, PSP_O_RDONLY, 0777);
if(fd < 0)
return NULL;
long filesize;
filesize = sceIoLseek32(fd, 0, PSP_SEEK_END);
sceIoLseek32(fd, 0, PSP_SEEK_SET);
unsigned char *data = pgeMalloc(filesize);
if(!data)
return NULL;
sceIoRead(fd, data, filesize);
sceIoClose(fd);
pgeObj *obj = pgeObjLoadInternal(data, filesize);
if(data)
pgeFree(data);
return obj;
}
示例15: sctrlSEGetConfig
int sctrlSEGetConfig(TNConfig *config)
{
int k1 = pspSdkSetK1(0);
memset(config, 0, sizeof(TNConfig));
/* Default settings */
strcpy(config->nickname, "CEF User");
config->exit_button_1 = 2; //PSP_CTRL_START
config->exit_hold_duration = 2;
config->button_assign = 1; //CROSS
config->show_pic1 = 1; //enabled
SceUID fd = sceIoOpen("ms0:/PSP/SYSTEM/CONFIG.TN", PSP_O_RDONLY, 0);
if(fd < 0)
{
pspSdkSetK1(k1);
return fd;
}
int read = sceIoRead(fd, config, sizeof(TNConfig));
sceIoClose(fd);
pspSdkSetK1(k1);
return read;
}