MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cupsDirRead

Function cupsDirRead

cups/dir.c:143–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141 */
142
143cups_dentry_t * /* O - Directory entry or @code NULL@ if there are no more */
144cupsDirRead(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...

Callers 15

mimeLoadFiltersFunction · 0.85
mimeLoadTypesFunction · 0.85
load_driversFunction · 0.85
load_ppdsFunction · 0.85
cupsdCleanFilesFunction · 0.85
cupsdLoadBannersFunction · 0.85
cupsdLoadAllJobsFunction · 0.85
load_request_rootFunction · 0.85
type_dirFunction · 0.85
mainFunction · 0.85
cupsdCreateCommonDataFunction · 0.85
load_quirksFunction · 0.85

Calls 2

_cups_dir_timeFunction · 0.85
statClass · 0.70

Tested by 5

type_dirFunction · 0.68
valid_pathFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68