forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[SOLVED]Help with file info...

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Wed Mar 26, 2008 3:38 am    Post subject: [SOLVED]Help with file info... Reply with quote

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
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Wed Mar 26, 2008 5:08 am    Post subject: Reply with quote

Take a look at pspiofilemgr_stat.h
Back to top
View user's profile Send private message
daaa57150



Joined: 17 Nov 2006
Posts: 28

PostPosted: Thu Mar 27, 2008 1:44 am    Post subject: Reply with quote

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:

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 (ok<=0)
             break;
           
          //extract info from dir
          if(dir.d_stat.st_attr & FIO_SO_IFDIR)
          {
             res=true;
          }
         }
         sceIoDclose(dfd);
   }
   
   return res;
}


I have those filesystem related functions if you want:
Code:
list<string> *directoryListFiles(string folder);
list<string> *directoryListFolders(string folder);
bool fileExists(string file);
bool directoryExists(string dir);
string getCurrentDirectory();
bool createDirectory(string dir);
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Thu Mar 27, 2008 4:25 am    Post subject: Reply with quote

You'd be better doing something like this:

Code:
int isFolder(const char *path)
{
   SceIoStat stats;
   sceIoGetstat(path, &stats);
   
   if (stats.st_mode & FIO_S_IFDIR)
      return 1;

   return 0; 
}
Back to top
View user's profile Send private message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Thu Mar 27, 2008 5:26 am    Post subject: Reply with quote

Tanks...
Back to top
View user's profile Send private message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Thu Mar 27, 2008 8:34 am    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group