![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to man readdir(3) | cy163 | UNIX for Dummies Questions & Answers | 1 | 07-07-2007 05:17 AM |
| Strange requirement!!! | rahul26 | UNIX for Advanced & Expert Users | 1 | 08-19-2006 12:29 AM |
| Preblem with readdir system call | gandhevinod | Filesystems, Disks and Memory | 2 | 02-16-2005 11:03 PM |
| system requirement for unix | gparsons70 | UNIX for Dummies Questions & Answers | 3 | 10-24-2001 12:56 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi all,
im using dirent.h headers readdir() function to traverse down a directory ( after openning it with opendir() ), and im printing the dir->d_name in a program. Code:
while(( dir = readdir( d ) ) != NULL ){
if (stat([path+dir->d_name], &info) != 0){
fprintf(stderr, "stat() error on %s: %s\n", path, strerror(errno));
continue;
}
if (S_ISDIR(info.st_mode) || S_ISREG(info.st_mode)) {
printf("%s\n", dir->d_name);
}
else{continue;}
}
but the output this gives is not sorted according to any parameter(name, date.etc..). is there a way to get such a sorted output using above dirent.h function calls or any other. any help is greatly appreciated. wolwy. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Check out scandir(3) and alphasort().
|
|
#3
|
|||
|
|||
|
Thankx fpmurphy for the reply, actually i had it given up until i saw ur answer recently. it worked, up to my requirement, thankx.
wolwy. |
|||
| Google The UNIX and Linux Forums |