本文整理汇总了C++中sceIoClose函数的典型用法代码示例。如果您正苦于以下问题:C++ sceIoClose函数的具体用法?C++ sceIoClose怎么用?C++ sceIoClose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sceIoClose函数的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: IoClose_new
int IoClose_new( PspIoDrvFileArg * arg )
{
PspIoDrvArg * drv = arg->drv;
int num = isRedirected( arg );
if( num >= 0 && arg->fs_num == 0 )
{
arg->drv = ms_drv;
handler_count --;
memcpy( &ctf_handler[num], &ctf_handler[num + 1], sizeof( CtfHandler ) * ( handler_count - num ) );
int ret = fatms_drv->funcs->IoClose( arg );
arg->drv = drv;
return ret;
}
if ( arg->arg == t_record )
{
log( "write finished!\n" );
int fd = sceIoOpen( CXMB_CONF_FILE, PSP_O_RDWR | PSP_O_CREAT | PSP_O_TRUNC, 0777 );
if ( fd < 0 )
{
log( "failed in openning %s\n", CXMB_CONF_FILE );
}
else
{
sceIoWrite( fd, selected_theme_file, strlen( selected_theme_file ) + 1 );
sceIoClose( fd );
}
IoClose( arg );
sceKernelSignalSema( sema, 1 );
}
arg->drv = drv;
int ret = IoClose(arg);
return ret;
}
示例3: retro_fclose
int retro_fclose(RFILE *stream)
{
if (!stream)
return -1;
#if defined(VITA) || defined(PSP)
if (stream->fd > 0)
sceIoClose(stream->fd);
#elif defined(__CELLOS_LV2__)
if (stream->fd > 0)
cellFsClose(stream->fd);
#else
#if defined(HAVE_BUFFERED_IO)
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
{
if (stream->fp)
fclose(stream->fp);
}
else
#endif
#ifdef HAVE_MMAP
if (stream->hints & RFILE_HINT_MMAP)
munmap(stream->mapped, stream->mapsize);
#endif
if (stream->fd > 0)
close(stream->fd);
#endif
free(stream);
return 0;
}
示例4: fclose
/*
**
** [func] - fclose.
** [desc] - if stream is a valid FILE stream and able to close the stream file
** then returns 0. else returns EOF.
** [entr] - FILE *stream; the pointer to the FILE stream.
** [exit] - int; 0 if able to close the stream file. else EOF.
** [prec] - stream is a valid FILE pointer.
** [post] - the stream file is closed.
**
*/
int fclose(FILE *stream)
{
int ret;
/* test the file stream type. */
switch(LOCAL_FILE(stream)->type) {
case STD_IOBUF_TYPE_NONE:
case STD_IOBUF_TYPE_GE:
case STD_IOBUF_TYPE_STDOUTHOST:
/* cannot close stdin, stdout, or stderr. */
// duh.. this is wrong. One SHOULD be able to close
// std*. That's a common unix doing. However, I doubt
// allowing this madness could be a good idea.
ret = EOF;
break;
default:
if ((LOCAL_FILE(stream)->fd >= 0) && (sceIoClose(LOCAL_FILE(stream)->fd) >= 0)) {
LOCAL_FILE(stream)->type = STD_IOBUF_TYPE_NONE;
LOCAL_FILE(stream)->fd = -1;
LOCAL_FILE(stream)->cnt = 0;
LOCAL_FILE(stream)->flag = 0;
ret = 0;
}
else ret = EOF;
}
return (ret);
}
示例5: pspgl_ge_writefile
static
void pspgl_ge_writefile (void *buf, unsigned long len)
{
int fd = sceIoOpen(PSPGL_GE_DUMPFILE, PSP_O_CREAT | PSP_O_APPEND | PSP_O_WRONLY, 0644);
sceIoWrite(fd, buf, len);
sceIoClose(fd);
}
示例6: sceIoOpen
frame_t *frame_factory_from_cfg_file(const char *cfg_file)
{
SceUID fd = -1;
frame_cfg_t *cfg = NULL;
frame_t *ret = NULL;
fd = sceIoOpen(cfg_file, PSP_O_RDONLY, 0777);
if (fd < 0) {
printf("can't open cfg file!\n");
goto cleanup;
}
cfg = frame_factory_read_cfg(fd);
if (cfg == NULL) {
printf("read cfg failed!\n");
goto cleanup;
}
ret = frame_factory_from_cfg(cfg);
cleanup:
if (fd >= 0) {
sceIoClose(fd);
}
if (cfg != NULL) {
free(cfg);
}
return ret;
}
示例7: receive_file
static void receive_file(ClientInfo *client, const char *path)
{
unsigned char *buffer;
SceUID fd;
unsigned int bytes_recv;
DEBUG("Opening: %s\n", path);
if ((fd = sceIoOpen(path, PSP2_O_CREAT | PSP2_O_WRONLY | PSP2_O_TRUNC, 0777)) >= 0) {
buffer = malloc(FILE_BUF_SIZE);
if (buffer == NULL) {
client_send_ctrl_msg(client, "550 Could not allocate memory.\n");
return;
}
client_open_data_connection(client);
client_send_ctrl_msg(client, "150 Opening Image mode data transfer.\n");
while ((bytes_recv = client_send_recv_raw(client, buffer, FILE_BUF_SIZE)) > 0) {
sceIoWrite(fd, buffer, bytes_recv);
}
sceIoClose(fd);
free(buffer);
client_send_ctrl_msg(client, "226 Transfer completed.\n");
client_close_data_connection(client);
} else {
client_send_ctrl_msg(client, "550 File not found.\n");
}
}
示例8: load_quest_index
int load_quest_index() {
mib_table = NULL;
mib_elems = 0;
k1 = pspSdkSetK1(0);
model_go = sceKernelGetModel() == 4 ? 1 : 0;
strcpy(filename, "xxx:/mhp3rd/quest/mib_id.dat");
SET_DEVICENAME(filename, model_go);
kprintf("trying to open %s\n", filename);
SceUID fd = sceIoOpen(filename, PSP_O_RDONLY, 0777);
if(fd < 0) {
kprintf("Cannot find mib_id.dat\n");
pspSdkSetK1(k1);
return fd;
}
SceSize size = (SceSize)sceIoLseek(fd, 0, PSP_SEEK_END);
sceIoLseek(fd, 0, PSP_SEEK_SET);
index_id = sceKernelAllocPartitionMemory(PSP_MEMORY_PARTITION_KERNEL, "mhp3mib", PSP_SMEM_High, size, NULL);
if(index_id >= 0) {
mib_table = sceKernelGetBlockHeadAddr(index_id);
sceIoRead(fd, mib_table, size);
mib_elems = size / (sizeof(u32) * 2);
quest_number = mib_table + mib_elems;
kprintf("index size: %i bytes, entries: %i\n", size, index_elems);
} else {
kprintf("failed to allocate memory for table\n");
}
sceIoClose(fd);
pspSdkSetK1(k1);
return 0;
}
示例9: diva_poll
int diva_poll(SceUID fd, SceInt64 *res) {
int ret;
u32 k1;
if(wait_fd >= 0 && fd == datafd) {
kprintf("polling for fd: %08X\n", wait_fd);
k1 = pspSdkSetK1(0);
ret = sceIoPollAsync(wait_fd, res);
if(ret <= 0) {
if(ret == 0) {
kprintf("Async read completed: %i bytes\n", (u32)*res);
*res = wait_size;
} else {
kprintf("polling error: %08X\n", ret);
}
sceIoClose(wait_fd);
wait_fd = -1;
} else {
kprintf("poll result: %08X\n", ret);
}
pspSdkSetK1(k1);
return ret;
}
return sceIoPollAsync(fd, res);
}
示例10: is_encrypted
static int is_encrypted(const char *path)
{
SceUID fd = -1;
u32 magic;
u32 result = 0;
fd = sceIoOpen(path, PSP_O_RDONLY, 0);
if (fd < 0) {
goto exit;
}
if (sizeof(magic) != sceIoRead(fd, &magic, sizeof(magic))) {
goto exit;
}
if (CRYPT_MAGIC == magic) {
result = 1;
}
exit:
if (fd >= 0) {
sceIoClose(fd);
fd = -1;
}
return result;
}
示例11: save_passwords
bool save_passwords(void)
{
password *pwd;
SceUID fd;
char path[PATH_MAX];
u32 magic;
STRCPY_S(path, scene_appdir());
STRCAT_S(path, "password.lst");
rc4_prepare_key((u8 *) CRYPT_KEY, sizeof(CRYPT_KEY) - 1, &g_key);
fd = sceIoOpen(path, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
if (fd < 0) {
return false;
}
magic = CRYPT_MAGIC;
sceIoWrite(fd, &magic, sizeof(magic));
for (pwd = g_pwd_head.next; pwd != NULL; pwd = pwd->next) {
write_chars(fd, pwd->b->ptr, strlen(pwd->b->ptr));
write_chars(fd, "\r\n", sizeof("\r\n") - 1);
}
sceIoClose(fd);
return true;
}
示例12: locate_umd_img1
int locate_umd_img1(const char *umdfile, size_t file_offset, SceUID * pfd)
{
int ret = -1;
char buf[9] = { 0 };
size_t stread = 0;
if (!umdfile || !pfd || file_offset < 0)
return -1;
*pfd = -1;
do {
struct UMDHeaderDataEx *pEx;
if ((*pfd = sceIoOpen(umdfile, PSP_O_RDONLY, 0777)) < 0) {
return -2;
}
if (0 < sceIoLseek(*pfd, file_offset, SEEK_SET))
return -3;
if ((stread = sceIoRead(*pfd, buf, 9)) < 0) {
dbg_printf(d, "%s read umd file head chunk error!", __func__);
break;
}
pEx = (struct UMDHeaderDataEx *) &buf;
if (!pEx || pEx->Mark != '$' || pEx->Length < 9)
break;
return pEx->Length - 9;
} while (false);
if (*pfd) {
sceIoClose(*pfd);
*pfd = -1;
}
return ret;
}
示例13: MP3SleepCheck
static int MP3SleepCheck(void)
{
if (Sleep)
{
if (mp3_fd >= 0) sceIoClose(mp3_fd);
mp3_sleep = 1;
do
{
sceKernelDelayThread(5000000);
} while (Sleep);
mp3_sleep = 0;
if ((mp3_fd = sceIoOpen(MP3_file, PSP_O_RDONLY, 0777)) < 0)
{
mp3_fd = -1;
mp3_status = MP3_STOP;
ui_popup(TEXT(COULD_NOT_REOPEN_MP3_FILEx), strrchr(MP3_file, '/') + 1);
return 1;
}
sceIoLseek(mp3_fd, mp3_filepos, PSP_SEEK_SET);
}
else if (mp3_status == MP3_STOP)
{
return 1;
}
return 0;
}
示例14: makeTestFile
int makeTestFile(const char *name) {
SceUID fd = sceIoOpen(name, PSP_O_WRONLY | PSP_O_CREAT, 0777);
if (fd < 0) {
return fd;
}
return sceIoClose(fd);
}
示例15: filestream_close
int filestream_close(RFILE *stream)
{
if (!stream)
goto error;
if (stream->ext)
free(stream->ext);
#if defined(PSP)
if (stream->fd > 0)
sceIoClose(stream->fd);
#else
#if defined(HAVE_BUFFERED_IO)
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
{
if (stream->fp)
fclose(stream->fp);
}
else
#endif
#ifdef HAVE_MMAP
if (stream->hints & RFILE_HINT_MMAP)
munmap(stream->mapped, stream->mapsize);
#endif
if (stream->fd > 0)
close(stream->fd);
#endif
free(stream);
return 0;
error:
return -1;
}