[SOLVED]Help with file info...

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

Moderators: cheriff, TyRaNiD

Post Reply
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

[SOLVED]Help with file info...

Post by ne0h »

Excuse me for another post,
I've to get the info of a file ( if is a dir or a file) and if is possible other info,
( creation date, ... ), i've read the pspiofilemgr but there is no function like this! Can anyone help me...
Tanks in advance!
Last edited by ne0h on Fri Mar 28, 2008 6:21 am, edited 1 time in total.
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Take a look at pspiofilemgr_stat.h
daaa57150
Posts: 28
Joined: Fri Nov 17, 2006 10:35 pm

Post by daaa57150 »

That's some code I found and mixed together to see if a file is a file or a folder. I don't know why the "for" loop is there but that works. If you want to test if it's a file rather than a folder, replace "FIO_SO_IFDIR" with "FIO_SO_IFREG":

Code: Select all

bool isFolder(string folder)
{
	SceIoDirent dir;
	int dfd, ok;
	bool res=false;
	
	dfd = sceIoDopen(folder.c_str());
	if (dfd>=0)
	{
	   	for (;;)
	   	{
	   		
		    memset(&dir, 0, sizeof dir);
		    ok = sceIoDread(dfd, &dir);
		    if &#40;ok<=0&#41; 
		    	break;
		      
		    //extract info from dir
		    if&#40;dir.d_stat.st_attr & FIO_SO_IFDIR&#41; 
		    &#123;
		    	res=true;
		    &#125;
	   	&#125;
	   	sceIoDclose&#40;dfd&#41;;
	&#125;
	
	return res;
&#125;
I have those filesystem related functions if you want:

Code: Select all

list<string> *directoryListFiles&#40;string folder&#41;;
list<string> *directoryListFolders&#40;string folder&#41;;
bool fileExists&#40;string file&#41;;
bool directoryExists&#40;string dir&#41;;
string getCurrentDirectory&#40;&#41;;
bool createDirectory&#40;string dir&#41;;
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

You'd be better doing something like this:

Code: Select all

int isFolder&#40;const char *path&#41;
&#123; 
	SceIoStat stats;
	sceIoGetstat&#40;path, &stats&#41;;
	
	if &#40;stats.st_mode & FIO_S_IFDIR&#41; 
		return 1; 

	return 0;  
&#125;
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

Tanks...
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

How to get the size, create date etc..?
I've try with printf("%d", stats.st_size); ( defined in stat.h ) but the programm crash!
Post Reply