Lines Matching +full:- +full:- +full:directory
2 * Directory routines for CUPS.
4 * This set of APIs abstracts enumeration of directory entries.
6 * Copyright 2007-2017 by Apple Inc.
7 * Copyright 1997-2005 by Easy Software Products, all rights reserved.
20 #include "string-private.h"
21 #include "debug-private.h"
36 struct _cups_dir_s /**** Directory data structure ****/
38 char directory[1024]; /* Directory filename */ member
39 HANDLE dir; /* Directory handle */
40 cups_dentry_t entry; /* Directory entry */
45 * '_cups_dir_time()' - Convert a FILETIME value to a UNIX time value.
48 time_t /* O - UNIX time */
49 _cups_dir_time(FILETIME ft) /* I - File time */ in _cups_dir_time()
61 return ((time_t)(val / 10000000 - 11644732800)); in _cups_dir_time()
66 * 'cupsDirClose()' - Close a directory.
72 cupsDirClose(cups_dir_t *dp) /* I - Directory pointer */ in cupsDirClose()
82 * Close an open directory handle... in cupsDirClose()
85 if (dp->dir != INVALID_HANDLE_VALUE) in cupsDirClose()
86 FindClose(dp->dir); in cupsDirClose()
97 * 'cupsDirOpen()' - Open a directory.
102 cups_dir_t * /* O - Directory pointer or @code NULL@ if the directory could not be opened. */
103 cupsDirOpen(const char *directory) /* I - Directory name */ in cupsDirOpen() argument
105 cups_dir_t *dp; /* Directory */ in cupsDirOpen()
112 if (!directory) in cupsDirOpen()
116 * Allocate memory for the directory structure... in cupsDirOpen()
124 * Copy the directory name for later use... in cupsDirOpen()
127 dp->dir = INVALID_HANDLE_VALUE; in cupsDirOpen()
129 strlcpy(dp->directory, directory, sizeof(dp->directory)); in cupsDirOpen()
132 * Return the new directory structure... in cupsDirOpen()
140 * 'cupsDirRead()' - Read the next directory entry.
145 cups_dentry_t * /* O - Directory entry or @code NULL@ if there are no more */
146 cupsDirRead(cups_dir_t *dp) /* I - Directory pointer */ in cupsDirRead()
148 WIN32_FIND_DATA entry; /* Directory entry data */ in cupsDirRead()
162 if (dp->dir == INVALID_HANDLE_VALUE) in cupsDirRead()
168 dp->dir = FindFirstFile(dp->directory, &entry); in cupsDirRead()
169 if (dp->dir == INVALID_HANDLE_VALUE) in cupsDirRead()
172 else if (!FindNextFile(dp->dir, &entry)) in cupsDirRead()
179 strlcpy(dp->entry.filename, entry.cFileName, sizeof(dp->entry.filename)); in cupsDirRead()
182 dp->entry.fileinfo.st_mode = 0755 | S_IFDIR; in cupsDirRead()
184 dp->entry.fileinfo.st_mode = 0644; in cupsDirRead()
186 dp->entry.fileinfo.st_atime = _cups_dir_time(entry.ftLastAccessTime); in cupsDirRead()
187 dp->entry.fileinfo.st_ctime = _cups_dir_time(entry.ftCreationTime); in cupsDirRead()
188 dp->entry.fileinfo.st_mtime = _cups_dir_time(entry.ftLastWriteTime); in cupsDirRead()
189 …dp->entry.fileinfo.st_size = entry.nFileSizeLow + ((unsigned long long)entry.nFileSizeHigh << 32); in cupsDirRead()
195 return (&(dp->entry)); in cupsDirRead()
200 * 'cupsDirRewind()' - Rewind to the start of the directory.
206 cupsDirRewind(cups_dir_t *dp) /* I - Directory pointer */ in cupsDirRewind()
216 * Close an open directory handle... in cupsDirRewind()
219 if (dp->dir != INVALID_HANDLE_VALUE) in cupsDirRewind()
221 FindClose(dp->dir); in cupsDirRewind()
222 dp->dir = INVALID_HANDLE_VALUE; in cupsDirRewind()
241 struct _cups_dir_s /**** Directory data structure ****/
243 char directory[1024]; /* Directory filename */ member
244 DIR *dir; /* Directory file */
245 cups_dentry_t entry; /* Directory entry */
250 * 'cupsDirClose()' - Close a directory.
256 cupsDirClose(cups_dir_t *dp) /* I - Directory pointer */ in cupsDirClose()
268 * Close the directory and free memory... in cupsDirClose()
271 closedir(dp->dir); in cupsDirClose()
277 * 'cupsDirOpen()' - Open a directory.
282 cups_dir_t * /* O - Directory pointer or @code NULL@ if the directory could not be opened. */
283 cupsDirOpen(const char *directory) /* I - Directory name */ in cupsDirOpen() argument
285 cups_dir_t *dp; /* Directory */ in cupsDirOpen()
288 DEBUG_printf(("cupsDirOpen(directory=\"%s\")", directory)); in cupsDirOpen()
294 if (!directory) in cupsDirOpen()
298 * Allocate memory for the directory structure... in cupsDirOpen()
306 * Open the directory... in cupsDirOpen()
309 dp->dir = opendir(directory); in cupsDirOpen()
310 if (!dp->dir) in cupsDirOpen()
317 * Copy the directory name for later use... in cupsDirOpen()
320 strlcpy(dp->directory, directory, sizeof(dp->directory)); in cupsDirOpen()
323 * Return the new directory structure... in cupsDirOpen()
331 * 'cupsDirRead()' - Read the next directory entry.
336 cups_dentry_t * /* O - Directory entry or @code NULL@ when there are no more */
337 cupsDirRead(cups_dir_t *dp) /* I - Directory pointer */ in cupsDirRead()
362 if ((entry = readdir(dp->dir)) == NULL) in cupsDirRead()
368 DEBUG_printf(("4cupsDirRead: readdir() returned \"%s\"...", entry->d_name)); in cupsDirRead()
374 if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) in cupsDirRead()
381 strlcpy(dp->entry.filename, entry->d_name, sizeof(dp->entry.filename)); in cupsDirRead()
383 snprintf(filename, sizeof(filename), "%s/%s", dp->directory, entry->d_name); in cupsDirRead()
385 if (stat(filename, &(dp->entry.fileinfo))) in cupsDirRead()
387 DEBUG_printf(("3cupsDirRead: stat() failed for \"%s\" - %s...", filename, in cupsDirRead()
396 return (&(dp->entry)); in cupsDirRead()
402 * 'cupsDirRewind()' - Rewind to the start of the directory.
408 cupsDirRewind(cups_dir_t *dp) /* I - Directory pointer */ in cupsDirRewind()
420 * Rewind the directory... in cupsDirRewind()
423 rewinddir(dp->dir); in cupsDirRewind()