Directory Manipulation Programming Algorithm in UNIX Linux lap program

Source code directory Manipulation Programming Algorithm
#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<sys/dir.h>
#define MAX CHARS 200
int char read, tmp;
struct direct *DirEntryPtr;
DIR *dirptr;
Struct stat Stat;
char path [MAX_CHARS];
main(argc,argc)
int argc;
char **argv
{
dirptr=opendir(argv[1]);
while(1)
DirEntryPtr=readdir(dirptr);
if(DirEntryPtr==0)
break;
if(strcmp(DirEntryPtr->d_name,”.”)!=0&&
strcmp(DirEntryPtr->d_name,”..”)
{
printf(“%s”, DirEntryPtr->d_name);
tmp=stat(path,&Stat)
if(S_ISDIR (Stat.st mode))
printf(“*”);
printf(“\n”);
}
}
}

OUTPUT CS1252 Operating Systems lap
[redhat35@localhost Rhel5]$ cc dm.c
[redhat35@localhost Rhel5]$ ./a.out
.a.sh.swp b.c r1
sf.sh fm.c dm.c
e.sh c.c r2
sw.sh output 2 .dm.c.swp
fp.sh c .dm.c.swpo
df.sh output1
a.out r1
a.c dm.c
b.c.swp r2
c.sh .dm.c.swp

Related post