getfilesize function

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Klimru
Posts: 34
Joined: Sat Apr 09, 2005 7:29 am

getfilesize function

Post by Klimru »

Maybe this will be useful for someone...

Code: Select all

unsigned long getfilesize(const char *filepath) {
	psp_stats pstat;
	sceIoGetstat(filepath,&pstat);
	return pstat.filesize;
}

------

typedef struct {
	unsigned long unknown[2];
	unsigned long filesize;
	unsigned long unknown2[24]; // guestimate
} psp_stats;

void sceIoGetstat(const char *file, psp_stats *statx);

------

Example:
fs = getfilesize("flash0:/vsh/resource/12.bmp");
The unknowns have a lot of info in them... i just dont feel like sorting it out at the moment. For the code i'm writing now, I really only want the file size.

-Klim
Vampire
Posts: 138
Joined: Tue Apr 12, 2005 8:16 am

Post by Vampire »

another possibility is to seek the end of the file:

Code: Select all

filesize = sceIoLseek(fd, 0, SEEK_END);
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

But seeking requires you to open and close the file, even if you aren't planning on reading from it :).
Post Reply