Lines Matching +full:- +full:filename

4  * Copyright © 2007-2014 by Apple Inc.
5 * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
27 * 'cupsdCleanFiles()' - Clean out old files.
31 cupsdCleanFiles(const char *path, /* I - Directory to clean */ in cupsdCleanFiles()
32 const char *pattern) /* I - Filename pattern or NULL */ in cupsdCleanFiles()
36 char filename[1024]; /* Filename */ in cupsdCleanFiles() local
46 cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open directory \"%s\" - %s", in cupsdCleanFiles()
55 if (pattern && fnmatch(pattern, dent->filename, 0)) in cupsdCleanFiles()
58 snprintf(filename, sizeof(filename), "%s/%s", path, dent->filename); in cupsdCleanFiles()
60 if (S_ISDIR(dent->fileinfo.st_mode)) in cupsdCleanFiles()
62 cupsdCleanFiles(filename, pattern); in cupsdCleanFiles()
64 status = rmdir(filename); in cupsdCleanFiles()
67 status = cupsdUnlinkOrRemoveFile(filename); in cupsdCleanFiles()
70 cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to remove \"%s\" - %s", filename, in cupsdCleanFiles()
79 * 'cupsdCloseCreatedConfFile()' - Close a created configuration file and move
83 int /* O - 0 on success, -1 on error */
85 cups_file_t *fp, /* I - File to close */ in cupsdCloseCreatedConfFile()
86 const char *filename) /* I - Filename */ in cupsdCloseCreatedConfFile() argument
88 char newfile[1024], /* filename.N */ in cupsdCloseCreatedConfFile()
89 oldfile[1024]; /* filename.O */ in cupsdCloseCreatedConfFile()
101 filename, strerror(errno)); in cupsdCloseCreatedConfFile()
103 return (-1); in cupsdCloseCreatedConfFile()
109 filename, strerror(errno)); in cupsdCloseCreatedConfFile()
111 return (-1); in cupsdCloseCreatedConfFile()
120 return (-1); in cupsdCloseCreatedConfFile()
123 * Then remove "filename.O", rename "filename" to "filename.O", and rename in cupsdCloseCreatedConfFile()
124 * "filename.N" to "filename". in cupsdCloseCreatedConfFile()
127 snprintf(newfile, sizeof(newfile), "%s.N", filename); in cupsdCloseCreatedConfFile()
128 snprintf(oldfile, sizeof(oldfile), "%s.O", filename); in cupsdCloseCreatedConfFile()
131 (rename(filename, oldfile) && errno != ENOENT) || in cupsdCloseCreatedConfFile()
132 rename(newfile, filename)) in cupsdCloseCreatedConfFile()
135 filename, strerror(errno)); in cupsdCloseCreatedConfFile()
136 return (-1); in cupsdCloseCreatedConfFile()
144 * 'cupsdClosePipe()' - Close a pipe as necessary.
148 cupsdClosePipe(int *fds) /* I - Pipe file descriptors (2) */ in cupsdClosePipe()
157 fds[0] = -1; in cupsdClosePipe()
163 fds[1] = -1; in cupsdClosePipe()
169 * 'cupsdCreateConfFile()' - Create a configuration file safely.
172 cups_file_t * /* O - File pointer */
174 const char *filename, /* I - Filename */ in cupsdCreateConfFile() argument
175 mode_t mode) /* I - Permissions */ in cupsdCreateConfFile()
178 char newfile[1024]; /* filename.N */ in cupsdCreateConfFile()
181 snprintf(newfile, sizeof(newfile), "%s.N", filename); in cupsdCreateConfFile()
204 * 'cupsdOpenConfFile()' - Open a configuration file.
206 * This function looks for "filename.O" if "filename" does not exist and does
210 cups_file_t * /* O - File pointer */
211 cupsdOpenConfFile(const char *filename) /* I - Filename */ in cupsdOpenConfFile() argument
216 if ((fp = cupsFileOpen(filename, "r")) == NULL) in cupsdOpenConfFile()
224 char oldfile[1024]; /* filename.O */ in cupsdOpenConfFile()
226 snprintf(oldfile, sizeof(oldfile), "%s.O", filename); in cupsdOpenConfFile()
230 cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open \"%s\": %s", filename, in cupsdOpenConfFile()
239 * 'cupsdOpenPipe()' - Create a pipe which is closed on exec.
242 int /* O - 0 on success, -1 on error */
243 cupsdOpenPipe(int *fds) /* O - Pipe file descriptors (2) */ in cupsdOpenPipe()
251 fds[0] = -1; in cupsdOpenPipe()
252 fds[1] = -1; in cupsdOpenPipe()
254 return (-1); in cupsdOpenPipe()
266 fds[0] = -1; in cupsdOpenPipe()
267 fds[1] = -1; in cupsdOpenPipe()
269 return (-1); in cupsdOpenPipe()
277 fds[0] = -1; in cupsdOpenPipe()
278 fds[1] = -1; in cupsdOpenPipe()
280 return (-1); in cupsdOpenPipe()
292 * 'cupsdRemoveFile()' - Remove a file securely.
295 int /* O - 0 on success, -1 on error */
296 cupsdRemoveFile(const char *filename) /* I - File to remove */ in cupsdRemoveFile() argument
303 if (access(filename, 0)) in cupsdRemoveFile()
306 cupsdLogMessage(CUPSD_LOG_DEBUG, "Securely removing \"%s\".", filename); in cupsdRemoveFile()
312 return (removefile(filename, NULL, REMOVEFILE_SECURE_1_PASS)); in cupsdRemoveFile()
325 if (access(filename, 0)) in cupsdRemoveFile()
328 cupsdLogMessage(CUPSD_LOG_DEBUG, "Securely removing \"%s\".", filename); in cupsdRemoveFile()
334 if ((fd = open(filename, O_WRONLY | O_EXCL)) < 0) in cupsdRemoveFile()
335 return (-1); in cupsdRemoveFile()
338 * Delete the file now - it will still be around as long as the file is in cupsdRemoveFile()
342 if (unlink(filename)) in cupsdRemoveFile()
345 return (-1); in cupsdRemoveFile()
355 return (-1); in cupsdRemoveFile()
369 return (-1); in cupsdRemoveFile()
382 * 'cupsdUnlinkOrRemoveFile()' - Unlink or securely remove a file depending
386 int /* O - 0 on success, -1 on error */
388 const char *filename) /* I - Filename */ in cupsdUnlinkOrRemoveFile() argument
391 return (cupsdRemoveFile(filename)); in cupsdUnlinkOrRemoveFile()
393 return (unlink(filename)); in cupsdUnlinkOrRemoveFile()
399 * 'overwrite_data()' - Overwrite the data in a file.
402 static int /* O - 0 on success, -1 on error */
403 overwrite_data(int fd, /* I - File descriptor */ in overwrite_data()
404 const char *buffer, /* I - Buffer to write */ in overwrite_data()
405 int bufsize, /* I - Size of buffer */ in overwrite_data()
406 int filesize) /* I - Size of file */ in overwrite_data()
416 return (-1); in overwrite_data()
430 return (-1); in overwrite_data()
432 filesize -= bytes; in overwrite_data()