gokernel
(usa Linux Mint)
Enviado em 14/03/2013 - 19:04h
Olá caro !!!
No linux veja algo sobre ( #include <sys/stat.h> ) ( struct stat)
#ifdef __WIN32__
#include "io.h"
#endif
#ifdef __linux__
#include <sys/stat.h>
#include <dirent.h>
#include <unistd.h>
#endif
/*
// WIN32 arquivo find:
//
struct _finddata_t
{
unsigned attrib; / Attributes, see constants above.
time_t time_create;
time_t time_access; // always midnight local time
time_t time_write;
_fsize_t size;
char name[FILENAME_MAX]; // may include spaces.
};
// LINUX arquivo find:
//
struct dirent
{
long d_ino; / inode number
off_t d_off; // offset to this dirent
unsigned short d_reclen; // length of this d_name
char d_name [NAME_MAX+1]; // file name (null-terminated)
}
*/
void win32_list_files (void)
{
int done;
struct _finddata_t find;
done = _findfirst("*.*", &find);
do {
if ( !(find.attrib & _A_SUBDIR) )
{
printf ("name: %s - size: %d\n", find.name, find.size);
}
} while ( !_findnext(done, &find) );
_findclose(done);
}
void linux_list_files (void)
{
DIR *dir;
struct dirent *entry;
struct stat s;
dir = opendir("./");
for (;;)
{
entry = readdir(dir);
if (!entry) break;
if ( !(stat(entry->d_name, &s) == 0 && S_ISDIR(s.st_mode)) )
{
printf ("name: %s - size: %ld\n", entry->d_name, s.st_size);
}
}// for (;;)
closedir(dir);
}
Espero que isso ja ajude .