Esempio n. 1
0
//  This is the initialiser and module loader
//  This is a general call, which loads the module from the 
//  given address into the modplayer
//
//  It basically loads into an internal format, so once this function
//  has returned the buffer at 'data' will not be needed again.
int XMPLAY_Load(char *filename)
{
    int fd;
    unsigned char *ptr;
    long size;
    if ((fd = sceIoOpen(filename, PSP_O_RDONLY, 0777)) > 0) {
	//  opened file, so get size now
	size = sceIoLseek(fd, 0, PSP_SEEK_END);
	sceIoLseek(fd, 0, PSP_SEEK_SET);

	if (filedataptr != 0) {
	    free(filedataptr);
	    filedataptr = 0;
	}

	ptr = (unsigned char *) malloc(size + 8);
	if (ptr != 0) {		// Read file in
	    filedataptr = ptr;
	    memset(ptr, 0, size + 8);
	    sceIoRead(fd, ptr, size);
	    // ok, read the file in, now do our stuff
	    return XMPLAY_InitTune(ptr, size);
	} else {
	    printf("Error allocing\n");
	    sceIoClose(fd);
	    return 0;
	}
	// Close file
	sceIoClose(fd);
    }
    m_bPlaying = 0;
    return 0;
}
Esempio n. 2
0
ssize_t _vfsceSize(struct VFile* vf) {
	struct VFileSce* vfsce = (struct VFileSce*) vf;
	SceOff cur = sceIoLseek(vfsce->fd, 0, SEEK_CUR);
	SceOff end = sceIoLseek(vfsce->fd, 0, SEEK_END);
	sceIoLseek(vfsce->fd, cur, SEEK_SET);
	return end;
}
Esempio n. 3
0
void *Red3dLoadFile(const char *path, int mempart)
{
	void *ptr, *readbuffer;
	
	int c = Red3dCheckFile(path);
	if(c >= 0) return DirIndex[c]->address;
	
	int fd = sceIoOpen(path, PSP_O_RDONLY, 0777);
	if(fd >= 0)
	{
		
		u32 size = sceIoLseek(fd, 0, SEEK_END); 
		sceIoLseek(fd, 0, SEEK_SET);
		
		readbuffer = malloc(size);
		sceIoRead(fd, readbuffer, size);
		
		ptr = Red3dLoadBuf(readbuffer, size, mempart);
		
		free(readbuffer);
		sceKernelDcacheWritebackInvalidateAll();
		sceIoClose(fd);
		
		return ptr;

	}
	return NULL;
}
Esempio n. 4
0
File: mp3.c Progetto: 173210/mvspsp
void mp3_seek_set(const char *name, UINT32 frame)
{
	if (mp3_thread >= 0)
	{
		strcpy(MP3_file, name);

		mp3_stop();

		if ((mp3_fd = sceIoOpen(MP3_file, PSP_O_RDONLY, 0777)) < 0)
		{
			mp3_fsize       = 0;
			mp3_status      = MP3_STOP;
			mp3_start_frame = 0;
			mp3_newfile     = 0;
		}
		else
		{
			mp3_fsize = sceIoLseek(mp3_fd, 0, PSP_SEEK_END);
			sceIoLseek(mp3_fd, 0, PSP_SEEK_SET);

			mp3_status      = MP3_SEEK;
			mp3_start_frame = frame;
			mp3_newfile     = 1;
		}
	}
}
Esempio n. 5
0
SceOff myNpDrmEdataGetDataSize(SceUID fd)
{
	SceOff end;

	if (sceKernelFindModuleByName("scePspNpDrm_Driver") == NULL) {
		end = 0x8002013A;
		goto exit;
	}
	
	if (is_nodrm_fd(fd)) {
		SceOff off;
	   
		off = sceIoLseek(fd, 0, PSP_SEEK_CUR);
		end = sceIoLseek(fd, 0, PSP_SEEK_END);
		sceIoLseek(fd, off, PSP_SEEK_SET);
	} else {
		if (_sceNpDrmEdataGetDataSize != NULL) {
			end = (*_sceNpDrmEdataGetDataSize)(fd);
		} else {
			end = 0x8002013A;
		}
	}

exit:
	printk("%s 0x%08X -> 0x%08X\n", __func__, fd, (uint)end);

	return end;
}
Esempio n. 6
0
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;
}
Esempio n. 7
0
int 
MP3_Load(char *filename)
{
  int fd;

  if (!strcmp(mp3_curr_filename, filename)) {
    // already loaded !
  } else
  if ((fd = sceIoOpen(filename, PSP_O_RDONLY, 0777)) > 0) {
    //  opened file, so get size now
    size = sceIoLseek(fd, 0, PSP_SEEK_END);
    sceIoLseek(fd, 0, PSP_SEEK_SET);
    if (mp3_data) { free(mp3_data); mp3_data = 0; }
    mp3_data = (unsigned char *) malloc(size + 8);
    if (mp3_data) memset(mp3_data, 0, size + 8);
    if (mp3_data != 0) {        // Read file in
      sceIoRead(fd, mp3_data, size);
    } else {
      //printf("Error allocing\n");
      sceIoClose(fd);
      return 0;
    }
    // Close file
    sceIoClose(fd);
    strcpy(mp3_curr_filename, filename);

  } else {
    return 0;
  }
  isPlaying = 0;
  FrameCount = 0;

  MP3_getInfo();
  return 1;
}
Esempio n. 8
0
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;
}
Esempio n. 9
0
static SceOff myIoLseek(SceUID fd, SceOff offset, int whence)
{
	SceOff ret;
	u32 k1;

	k1 = pspSdkSetK1(0);

	if(g_keys_bin_found || g_is_custom_ps1) {
		if (fd == RIF_MAGIC_FD) {
			printk("%s: [FAKE]\n", __func__);
			ret = 0;
		} else if (fd == ACT_DAT_FD) {
			printk("%s: [FAKE]\n", __func__);
			ret = 0;
		} else {
			ret = sceIoLseek(fd, offset, whence);
		}
	} else {
		ret = sceIoLseek(fd, offset, whence);
	}

	pspSdkSetK1(k1);
	printk("%s: 0x%08X 0x%08X 0x%08X -> 0x%08X\n", __func__, (uint)fd, (uint)offset, (uint)whence, (int)ret);

	return ret;
}
Esempio n. 10
0
/********************************************//**
 *  \brief Loads file to memory
 *  
 *  \returns Zero on success, otherwise error
 ***********************************************/
int
uvl_load_file (const char *filename,    ///< File to load
                     void **data,       ///< Output pointer to data
                  PsvSSize *size)       ///< Output pointer to data size
{
    PsvUID fd;
    PsvUID memblock;
    char *base;
    PsvOff filesz;
    PsvOff nread;
    PsvSSize nbytes;

    fd = sceIoOpen (filename, PSP2_O_RDONLY, 0);
    if (fd < 0)
    {
        LOG ("Failed to open %s for reading.", filename);
        return -1;
    }
    filesz = sceIoLseek (fd, 0LL, PSP2_SEEK_END);
    if (filesz < 0)
    {
        LOG ("Failed to find file size: 0x%X", filesz);
        return -1;
    }
    sceIoLseek (fd, 0LL, PSP2_SEEK_SET);
    memblock = sceKernelAllocMemBlock ("UVLTemp", 0xC20D060, (filesz + 0xFFF) & ~0xFFF, NULL);
    if (memblock < 0)
    {
        LOG ("Failed allocate %u bytes of memory.", memblock);
        return -1;
    }
    if (sceKernelGetMemBlockBase (memblock, &base) < 0)
    {
        LOG ("Failed to locate base for block 0x%08X.", memblock);
        return -1;
    }
    base = (char *)(((u32_t)base + 0xFFF) & ~0xFFF); // align memory base
    nbytes = 0;
    while ((nread = sceIoRead (fd, base+nbytes, filesz)) < filesz-nbytes)
    {
        nbytes += nread;
    }
    if (nbytes < 0)
    {
        LOG ("Failed to read %s: 0x%08X", filename, nbytes);
        return -1;
    }
    IF_DEBUG LOG ("Read %u bytes from %s", nbytes, filename);
    if (sceIoClose (fd) < 0)
    {
        LOG ("Failed to close file.");
        return -1;
    }

    *data = base;
    *size = nbytes;

    return 0;
}
Esempio n. 11
0
int fileGetSize(char *filein) {
	SceUID fd = sceIoOpen(filein, PSP_O_RDONLY, 0777);
	if (fd < 0)	return -1;
	fsize = sceIoLseek(fd, 0, SEEK_END);
	sceIoLseek(fd, 0, SEEK_SET);
	sceIoClose(fd);
	return fsize;
}
Esempio n. 12
0
static void _vfsceUnmap(struct VFile* vf, void* memory, size_t size) {
	struct VFileSce* vfsce = (struct VFileSce*) vf;
	SceOff cur = sceIoLseek(vfsce->fd, 0, SEEK_CUR);
	sceIoLseek(vfsce->fd, 0, SEEK_SET);
	sceIoWrite(vfsce->fd, memory, size);
	sceIoLseek(vfsce->fd, cur, SEEK_SET);
	sceIoSyncByFd(vfsce->fd);
	mappedMemoryFree(memory, size);
}
Esempio n. 13
0
bool _vfsceSync(struct VFile* vf, const void* buffer, size_t size) {
	struct VFileSce* vfsce = (struct VFileSce*) vf;
	if (buffer && size) {
		SceOff cur = sceIoLseek(vfsce->fd, 0, SEEK_CUR);
		sceIoLseek(vfsce->fd, 0, SEEK_SET);
		sceIoWrite(vfsce->fd, buffer, size);
		sceIoLseek(vfsce->fd, cur, SEEK_SET);
	}
	return sceIoSyncByFd(vfsce->fd) >= 0;
}
Esempio n. 14
0
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);
		}
	}
}
Esempio n. 15
0
static void* _vfsceMap(struct VFile* vf, size_t size, int flags) {
	struct VFileSce* vfsce = (struct VFileSce*) vf;
	UNUSED(flags);
	void* buffer = anonymousMemoryMap(size);
	if (buffer) {
		SceOff cur = sceIoLseek(vfsce->fd, 0, SEEK_CUR);
		sceIoLseek(vfsce->fd, 0, SEEK_SET);
		sceIoRead(vfsce->fd, buffer, size);
		sceIoLseek(vfsce->fd, cur, SEEK_SET);
	}
	return buffer;
}
Esempio n. 16
0
int fstat (int file,struct stat *st) {
  int size,cur;
  CHECKFILE(file);

  cur = sceIoLseek(file,0,SEEK_CUR);
  size = sceIoLseek(file,0,SEEK_END);
  sceIoLseek(file,cur,SEEK_SET);

  memset(st,0,sizeof(*st));

  st->st_mode = S_IFREG;
  st->st_size = size;
  return 0;
}
int MFFileNative_Seek(MFFile* fileHandle, int64 bytes, MFFileSeek relativity)
{
	MFCALLSTACK;

	int method = 0;

	switch(relativity)
	{
		case MFSeek_Begin:
			method = SEEK_SET;
			break;
		case MFSeek_End:
			method = SEEK_END;
			break;
		case MFSeek_Current:
			method = SEEK_CUR;
			break;
		default:
			MFDebug_Assert(false, "Invalid 'relativity' for file seeking.");
	}

	SceOff newPos = sceIoLseek((SceUID)fileHandle->pFilesysData, bytes, method);
	fileHandle->offset = (int64)newPos;
	return newPos;
}
Esempio n. 18
0
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;
}
Esempio n. 19
0
u32 sceIoLseekAsync(int id, s64 offset, int whence)
{
	DEBUG_LOG(HLE, "sceIoLseekAsync(%d) sorta implemented", id);
	sceIoLseek(id, offset, whence);
	__IoCompleteAsyncIO(id);
	return 0;
}
Esempio n. 20
0
ssize_t filestream_tell(RFILE *stream)
{
   if (!stream)
      return -1;
#if defined(VITA) || defined(PSP)
   return sceIoLseek(stream->fd, 0, SEEK_CUR);
#elif defined(__CELLOS_LV2__)
   uint64_t pos = 0;
   if (cellFsLseek(stream->fd, 0, CELL_FS_SEEK_CUR, &pos) != CELL_FS_SUCCEEDED)
      return -1;
   return 0;
#else
#if defined(HAVE_BUFFERED_IO)
   if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
      return ftell(stream->fp);
   else
#endif
#ifdef HAVE_MMAP
      /* Need to check stream->mapped because this function 
       * is called in filestream_open() */
      if (stream->mapped && stream->hints & RFILE_HINT_MMAP)
         return stream->mappos;
      else
#endif
         return lseek(stream->fd, 0, SEEK_CUR);
#endif
}
Esempio n. 21
0
ssize_t retro_fseek(RFILE *stream, ssize_t offset, int whence)
{
   int ret = 0;
   if (!stream)
      return -1;

   (void)ret;

#if defined(VITA) || defined(PSP)
   ret = sceIoLseek(stream->fd, (SceOff)offset, whence);
   if (ret == -1)
      return -1;
   return 0;
#elif defined(__CELLOS_LV2__)
   uint64_t pos = 0;
   if (cellFsLseek(stream->fd, offset, whence, &pos) != CELL_FS_SUCCEEDED)
      return -1;
   return 0;
#elif defined(HAVE_BUFFERED_IO)
   return fseek(stream->fd, (long)offset, whence);
#else
   ret = lseek(stream->fd, offset, whence);
   if (ret == -1)
      return -1;
   return 0;
#endif
}
Esempio n. 22
0
ssize_t filestream_tell(RFILE *stream)
{
   if (!stream)
      goto error;
#if  defined(PSP)
  if (sceIoLseek(stream->fd, 0, SEEK_CUR) < 0)
     goto error;
#else
#if defined(HAVE_BUFFERED_IO)
   if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
      return ftell(stream->fp);
#endif
#ifdef HAVE_MMAP
   /* Need to check stream->mapped because this function 
    * is called in filestream_open() */
   if (stream->mapped && stream->hints & RFILE_HINT_MMAP)
      return stream->mappos;
#endif
   if (lseek(stream->fd, 0, SEEK_CUR) < 0)
      goto error;
#endif

   return 0;

error:
   return -1;
}
Esempio n. 23
0
ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence)
{
   if (!stream)
      goto error;

#if  defined(PSP)
   if (sceIoLseek(stream->fd, (SceOff)offset, whence) == -1)
      goto error;
#else

#if defined(HAVE_BUFFERED_IO)
   if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
      return fseek(stream->fp, (long)offset, whence);
#endif

#ifdef HAVE_MMAP
   /* Need to check stream->mapped because this function is 
    * called in filestream_open() */
   if (stream->mapped && stream->hints & RFILE_HINT_MMAP)
   {
      /* fseek() returns error on under/overflow but allows cursor > EOF for
         read-only file descriptors. */
      switch (whence)
      {
         case SEEK_SET:
            if (offset < 0)
               goto error;

            stream->mappos = offset;
            break;

         case SEEK_CUR:
            if ((offset < 0 && stream->mappos + offset > stream->mappos) ||
                  (offset > 0 && stream->mappos + offset < stream->mappos))
               goto error;

            stream->mappos += offset;
            break;

         case SEEK_END:
            if (stream->mapsize + offset < stream->mapsize)
               goto error;

            stream->mappos = stream->mapsize + offset;
            break;
      }
      return stream->mappos;
   }
#endif

   if (lseek(stream->fd, offset, whence) < 0)
      goto error;

#endif

   return 0;

error:
   return -1;
}
Esempio n. 24
0
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;
}
Esempio n. 25
0
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;
}
Esempio n. 26
0
File: mp3.c Progetto: 173210/mvspsp
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;
}
Esempio n. 27
0
int  fseek ( FILE * fd, long offset , int origin ) {
	/*SEEK_SET (0) Beginning of file. 
SEEK_CUR (1) Current position of the file pointer. 
SEEK_END (2) End of file. 
*/
  sceIoLseek((int)fd, offset, origin);	
	return 0;
}
Esempio n. 28
0
static zzip_off_t psar_seek(int fd, zzip_off_t offset, int whence)
{
    switch(whence)
    {
    case PSP_SEEK_SET :
        return sceIoLseek(fd, (pOffset + offset), PSP_SEEK_SET) - pOffset;
        break;
    case PSP_SEEK_CUR:
        return sceIoLseek(fd, offset, PSP_SEEK_CUR) - pOffset;
        break;
    case PSP_SEEK_END:
        if(offset < 0) return sceIoLseek(fd, offset, PSP_SEEK_END) - pOffset;
        break;
        default: break;
    }

    return 0;
}
Esempio n. 29
0
static int psar_open(zzip_char_t *name, int flags, ...)
{
    int fd = sceIoOpen(name, PSP_O_RDONLY, 0777);

    if(fd < 0)
    {
        #ifdef DEBUG
        dwrite_output("Function %s Line %i : Cannot open the file '%s'.\n", __FUNCTION__, __LINE__, name);
        #endif
        return -1;
    }

    sceIoLseek(fd, 0x24, PSP_SEEK_SET);
    sceIoRead(fd, &pOffset, sizeof(u32));
    sceIoLseek(fd, pOffset, PSP_SEEK_SET);

    return (fd);
}
// 670
int cso_open(SceUID fd)
{
	int ret;
	u32 *magic;

	g_CISO_hdr.magic[0] = '\0';
	g_ciso_dec_buf_offset = (u32)-1;
	g_ciso_dec_buf_size = 0;

	sceIoLseek(fd, 0, PSP_SEEK_SET);
	ret = sceIoRead(fd, &g_CISO_hdr, sizeof(g_CISO_hdr));

	if(ret != sizeof(g_CISO_hdr)) {
		ret = -1;
		printk("%s: -> %d\n", __func__, ret);
		goto exit;
	}

	magic = (u32*)g_CISO_hdr.magic;

	if(*magic == 0x4F534943) { // CISO
		g_CISO_cur_idx = -1;
		ciso_total_block = g_CISO_hdr.total_bytes / g_CISO_hdr.block_size;
		printk("%s: total block %d\n", __func__, (int)ciso_total_block);

		if(g_ciso_dec_buf == NULL) {
			g_ciso_dec_buf = oe_malloc(CISO_DEC_BUFFER_SIZE + (1 << g_CISO_hdr.align) + 64);

			if(g_ciso_dec_buf == NULL) {
				ret = -2;
				printk("%s: -> %d\n", __func__, ret);
				goto exit;
			}

			if((u32)g_ciso_dec_buf & 63)
				g_ciso_dec_buf = (void*)(((u32)g_ciso_dec_buf & (~63)) + 64);
		}

		if(g_ciso_block_buf == NULL) {
			g_ciso_block_buf = oe_malloc(ISO_SECTOR_SIZE);

			if(g_ciso_block_buf == NULL) {
				ret = -3;
				printk("%s: -> %d\n", __func__, ret);
				goto exit;
			}
		}

		ret = 0;
	} else {
		ret = 0x8002012F;
	}

exit:
	return ret;
}