| 141 | */ |
| 142 | |
| 143 | cups_dentry_t * /* O - Directory entry or @code NULL@ if there are no more */ |
| 144 | cupsDirRead(cups_dir_t *dp) /* I - Directory pointer */ |
| 145 | { |
| 146 | WIN32_FIND_DATAA entry; /* Directory entry data */ |
| 147 | |
| 148 | |
| 149 | /* |
| 150 | * Range check input... |
| 151 | */ |
| 152 | |
| 153 | if (!dp) |
| 154 | return (NULL); |
| 155 | |
| 156 | /* |
| 157 | * See if we have already started finding files... |
| 158 | */ |
| 159 | |
| 160 | if (dp->dir == INVALID_HANDLE_VALUE) |
| 161 | { |
| 162 | /* |
| 163 | * No, find the first file... |
| 164 | */ |
| 165 | |
| 166 | dp->dir = FindFirstFileA(dp->directory, &entry); |
| 167 | if (dp->dir == INVALID_HANDLE_VALUE) |
| 168 | return (NULL); |
| 169 | } |
| 170 | else if (!FindNextFileA(dp->dir, &entry)) |
| 171 | return (NULL); |
| 172 | |
| 173 | /* |
| 174 | * Loop until we have something other than "." or ".."... |
| 175 | */ |
| 176 | |
| 177 | while (!strcmp(entry.cFileName, ".") || !strcmp(entry.cFileName, "..")) |
| 178 | { |
| 179 | if (!FindNextFileA(dp->dir, &entry)) |
| 180 | return (NULL); |
| 181 | } |
| 182 | |
| 183 | /* |
| 184 | * Copy the name over and convert the file information... |
| 185 | */ |
| 186 | |
| 187 | strlcpy(dp->entry.filename, entry.cFileName, sizeof(dp->entry.filename)); |
| 188 | |
| 189 | if (entry.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) |
| 190 | dp->entry.fileinfo.st_mode = 0755 | S_IFDIR; |
| 191 | else |
| 192 | dp->entry.fileinfo.st_mode = 0644 | S_IFREG; |
| 193 | |
| 194 | dp->entry.fileinfo.st_atime = _cups_dir_time(entry.ftLastAccessTime); |
| 195 | dp->entry.fileinfo.st_ctime = _cups_dir_time(entry.ftCreationTime); |
| 196 | dp->entry.fileinfo.st_mtime = _cups_dir_time(entry.ftLastWriteTime); |
| 197 | dp->entry.fileinfo.st_size = entry.nFileSizeLow + ((unsigned long long)entry.nFileSizeHigh << 32); |
| 198 | |
| 199 | /* |
| 200 | * Return the entry... |