| View previous topic :: View next topic |
| Author |
Message |
ne0h
Joined: 21 Feb 2008 Posts: 386
|
Posted: Wed Mar 26, 2008 3:38 am Post subject: [SOLVED]Help with file info... |
|
|
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 |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Wed Mar 26, 2008 5:08 am Post subject: |
|
|
| Take a look at pspiofilemgr_stat.h |
|
| Back to top |
|
 |
daaa57150
Joined: 17 Nov 2006 Posts: 28
|
Posted: Thu Mar 27, 2008 1:44 am Post subject: |
|
|
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 |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Thu Mar 27, 2008 4:25 am Post subject: |
|
|
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 |
|
 |
ne0h
Joined: 21 Feb 2008 Posts: 386
|
Posted: Thu Mar 27, 2008 5:26 am Post subject: |
|
|
| Tanks... |
|
| Back to top |
|
 |
ne0h
Joined: 21 Feb 2008 Posts: 386
|
Posted: Thu Mar 27, 2008 8:34 am Post subject: |
|
|
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 |
|
 |
|