Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Plain Text by Mhl ( 14 years ago )
#include <stdio.h>
#include <dirent.h>
#include <pwd.h>
#include <grp.h>
#include <unistd.h>
#include <sys/stat.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
DIR *folder;
struct dirent *name;
struct stat info;
struct tm *czas;
struct passwd *pw;
struct group *gr;
struct stat *buf=(struct stat*)malloc(sizeof(struct stat));
mode_t mode;
unsigned char usr[]="---";
unsigned char grp[]="---";
unsigned char oth[]="---";
char *buff;
int i;
buff=ctime(&buf;->st_atime);
if ((folder = opendir("."))==NULL)
perror("Zla sciezka podaj nowa");
else
{
while ((name=readdir(folder))!=NULL)
{
if(name->d_name[0] == '.') continue;
lstat(name->d_name,&info;);
stat(name->d_name, buf);
pw=getpwuid(info.st_uid);/*user id*/
gr=getgrgid(info.st_gid);/*group id*/
czas=gmtime(&info;.st_mtime);/*czas dostepu*/
mode=info.st_mode;
if( mode & S_IRUSR ) usr[0] = 'r';
if( mode & S_IWUSR ) usr[1] = 'w';
if( mode & S_IXUSR ) usr[2] = 'x';
if( mode & S_ISUID ) usr[2] = 's'; /* set UID bit*/
if( mode & S_IRGRP ) grp[0] = 'r';
if( mode & S_IWGRP ) grp[1] = 'w';
if( mode & S_IXGRP ) grp[2] = 'x';
if( mode & S_ISGID ) grp[2] = 's'; /* set GID bit*/
if( mode & S_IROTH ) oth[0] = 'r';
if( mode & S_IWOTH ) oth[1] = 'w';
if( mode & S_IXOTH ) oth[2] = 'x';
printf("%c %c %c %c %c %c %c %c %c ",usr[0],usr[1],usr[2],grp[0],grp[1],grp[2],oth[0],oth[1],oth[2]);
printf("%s ",pw->pw_name);
printf("%s ",gr->gr_name);
printf("%d ",(int)info.st_size);
for (i=0;i<24;i++)
printf("%c",buff[i]);
printf("%s\n",name->d_name);
}
}
return 0;
}
Revise this Paste