| Last change
 on this file since 2641 was             730, checked in by bird, 22 years ago | 
        
          | 
Initial coding.
 | 
        
          | 
              
Property                 cvs2svn:cvs-rev
 set to                 1.1
Property                 svn:eol-style
 set to                 native
Property                 svn:executable
 set to                 *
Property                 svn:keywords
 set to                 Author Date Id Revision | 
        
          | File size:
            499 bytes | 
      
      
| Rev | Line |  | 
|---|
| [730] | 1 | #include <dirent.h> | 
|---|
|  | 2 | #include <stdio.h> | 
|---|
|  | 3 | #include <errno.h> | 
|---|
|  | 4 |  | 
|---|
|  | 5 | int ls(const char *pszDir) | 
|---|
|  | 6 | { | 
|---|
|  | 7 | struct dirent * pdent; | 
|---|
|  | 8 | DIR *pDir = opendir(pszDir); | 
|---|
|  | 9 | if (!pDir) | 
|---|
|  | 10 | { | 
|---|
|  | 11 | printf("opendir failed on '%s'. errno=%d\n", pszDir, errno); | 
|---|
|  | 12 | return -1; | 
|---|
|  | 13 | } | 
|---|
|  | 14 |  | 
|---|
|  | 15 | printf("Directory: %s\n", pszDir); | 
|---|
|  | 16 | while ((pdent = readdir(pDir)) != NULL) | 
|---|
|  | 17 | { | 
|---|
|  | 18 | printf("\t%ld\t%s\n", (long)pdent->d_size, pdent->d_name); | 
|---|
|  | 19 | } | 
|---|
|  | 20 | closedir(pDir); | 
|---|
|  | 21 | return 0; | 
|---|
|  | 22 | } | 
|---|
|  | 23 |  | 
|---|
|  | 24 |  | 
|---|
|  | 25 | int main() | 
|---|
|  | 26 | { | 
|---|
|  | 27 | return ls("."); | 
|---|
|  | 28 | } | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.