Go to the source code of this file.
Classes | |
struct | dirent |
Typedefs | |
typedef struct DIR | DIR |
Functions | |
DIR * | opendir (const char *) |
int | closedir (DIR *) |
struct dirent * | readdir (DIR *) |
void | rewinddir (DIR *) |
int closedir | ( | DIR * | ) |
Definition at line 99 of file dirent.c.
00100 { 00101 int result = -1; 00102 00103 if(dir) 00104 { 00105 if(dir->handle != -1) 00106 { 00107 result = _findclose(dir->handle); 00108 } 00109 00110 free(dir->name); 00111 free(dir); 00112 } 00113 00114 if(result == -1) /* map all errors to EBADF */ 00115 { 00116 errno = EBADF; 00117 } 00118 00119 return result; 00120 }
DIR* opendir | ( | const char * | ) |
Definition at line 58 of file dirent.c.
00059 { 00060 DIR *dir = 0; 00061 00062 if(name && name[0]) 00063 { 00064 size_t base_length = strlen(name); 00065 const char *all = /* search pattern must end with suitable wildcard */ 00066 strchr("/\\", name[base_length - 1]) ? "*" : "/*"; 00067 00068 if((dir = (DIR *) malloc(sizeof *dir)) != 0 && 00069 (dir->name = (char *) malloc(base_length + strlen(all) + 1)) != 0) 00070 { 00071 strcat(strcpy(dir->name, name), all); 00072 00073 if((dir->handle = (long) _findfirst(dir->name, &dir->info)) != -1) 00074 { 00075 dir->result.d_name = 0; 00076 } 00077 else /* rollback */ 00078 { 00079 free(dir->name); 00080 free(dir); 00081 dir = 0; 00082 } 00083 } 00084 else /* rollback */ 00085 { 00086 free(dir); 00087 dir = 0; 00088 errno = ENOMEM; 00089 } 00090 } 00091 else 00092 { 00093 errno = EINVAL; 00094 } 00095 00096 return dir; 00097 }
Definition at line 122 of file dirent.c.
00123 { 00124 struct dirent *result = 0; 00125 00126 if(dir && dir->handle != -1) 00127 { 00128 if(!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1) 00129 { 00130 result = &dir->result; 00131 result->d_name = dir->info.name; 00132 } 00133 } 00134 else 00135 { 00136 errno = EBADF; 00137 } 00138 00139 return result; 00140 }
void rewinddir | ( | DIR * | ) |