/*
* "$Id$"
*
- * Public directory routines for the Common UNIX Printing System (CUPS).
+ * Directory routines for CUPS.
*
* This set of APIs abstracts enumeration of directory entries.
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2012 by Apple Inc.
* Copyright 1997-2005 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
* Include necessary headers...
*/
+#include "string-private.h"
+#include "debug-private.h"
#include "dir.h"
-#include "string.h"
-#include "debug.h"
-#include <stdlib.h>
-#include <errno.h>
/*
* between them...
*/
- val = ft.dwLowDateTime + (ft.dwHighDateTime << 32);
+ val = ft.dwLowDateTime + ((ULONGLONG)ft.dwHighDateTime << 32);
return ((time_t)(val / 10000000 - 11644732800));
}
/*
* 'cupsDirClose()' - Close a directory.
+ *
+ * @since CUPS 1.2/OS X 10.5@
*/
void
-cupsDirClose(cups_dir_t *dp) /* I - Directory */
+cupsDirClose(cups_dir_t *dp) /* I - Directory pointer */
{
/*
* Range check input...
/*
* 'cupsDirOpen()' - Open a directory.
+ *
+ * @since CUPS 1.2/OS X 10.5@
*/
-cups_dir_t * /* O - Directory */
+cups_dir_t * /* O - Directory pointer or @code NULL@ if the directory could not be opened. */
cupsDirOpen(const char *directory) /* I - Directory name */
{
cups_dir_t *dp; /* Directory */
/*
* 'cupsDirRead()' - Read the next directory entry.
+ *
+ * @since CUPS 1.2/OS X 10.5@
*/
-cups_dentry_t * /* O - Directory entry */
-cupsDirRead(cups_dir_t *dp) /* I - Directory */
+cups_dentry_t * /* O - Directory entry or @code NULL@ if there are no more */
+cupsDirRead(cups_dir_t *dp) /* I - Directory pointer */
{
WIN32_FIND_DATA entry; /* Directory entry data */
dp->entry.fileinfo.st_atime = _cups_dir_time(entry.ftLastAccessTime);
dp->entry.fileinfo.st_ctime = _cups_dir_time(entry.ftCreationTime);
dp->entry.fileinfo.st_mtime = _cups_dir_time(entry.ftLastWriteTime);
- dp->entry.fileinfo.st_size = entry.nFileSizeLow + (entry.nFileSizeHigh << 32);
+ dp->entry.fileinfo.st_size = entry.nFileSizeLow + ((unsigned long long)entry.nFileSizeHigh << 32);
/*
* Return the entry...
/*
* 'cupsDirRewind()' - Rewind to the start of the directory.
+ *
+ * @since CUPS 1.2/OS X 10.5@
*/
void
-cupsDirRewind(cups_dir_t *dp) /* I - Directory */
+cupsDirRewind(cups_dir_t *dp) /* I - Directory pointer */
{
/*
* Range check input...
/*
* 'cupsDirClose()' - Close a directory.
+ *
+ * @since CUPS 1.2/OS X 10.5@
*/
void
-cupsDirClose(cups_dir_t *dp) /* I - Directory */
+cupsDirClose(cups_dir_t *dp) /* I - Directory pointer */
{
- DEBUG_printf(("cupsDirClose(dp=%p)\n", dp));
+ DEBUG_printf(("cupsDirClose(dp=%p)", dp));
/*
* Range check input...
/*
* 'cupsDirOpen()' - Open a directory.
+ *
+ * @since CUPS 1.2/OS X 10.5@
*/
-cups_dir_t * /* O - Directory */
+cups_dir_t * /* O - Directory pointer or @code NULL@ if the directory could not be opened. */
cupsDirOpen(const char *directory) /* I - Directory name */
{
cups_dir_t *dp; /* Directory */
- DEBUG_printf(("cupsDirOpen(directory=\"%s\")\n", directory));
+ DEBUG_printf(("cupsDirOpen(directory=\"%s\")", directory));
/*
* Range check input...
/*
* 'cupsDirRead()' - Read the next directory entry.
+ *
+ * @since CUPS 1.2/OS X 10.5@
*/
-cups_dentry_t * /* O - Directory entry */
-cupsDirRead(cups_dir_t *dp) /* I - Directory */
+cups_dentry_t * /* O - Directory entry or @code NULL@ when there are no more */
+cupsDirRead(cups_dir_t *dp) /* I - Directory pointer */
{
struct dirent *entry; /* Pointer to entry */
char filename[1024]; /* Full filename */
# endif /* HAVE_PTHREAD_H */
- DEBUG_printf(("cupsDirRead(dp=%p)\n", dp));
+ DEBUG_printf(("2cupsDirRead(dp=%p)", dp));
/*
* Range check input...
if (readdir_r(dp->dir, (struct dirent *)buffer, &entry))
{
- DEBUG_printf((" readdir_r() failed - %s\n", strerror(errno)));
+ DEBUG_printf(("3cupsDirRead: readdir_r() failed - %s\n", strerror(errno)));
return (NULL);
}
if (!entry)
{
- DEBUG_puts(" readdir_r() returned a NULL pointer!");
+ DEBUG_puts("3cupsDirRead: readdir_r() returned a NULL pointer!");
return (NULL);
}
- DEBUG_printf((" readdir_r() returned \"%s\"...\n", entry->d_name));
+ DEBUG_printf(("4cupsDirRead: readdir_r() returned \"%s\"...",
+ entry->d_name));
# else
/*
if ((entry = readdir(dp->dir)) == NULL)
{
- DEBUG_puts(" readdir() returned a NULL pointer!");
+ DEBUG_puts("3cupsDirRead: readdir() returned a NULL pointer!");
return (NULL);
}
- DEBUG_printf((" readdir() returned \"%s\"...\n", entry->d_name));
+ DEBUG_printf(("4cupsDirRead: readdir() returned \"%s\"...", entry->d_name));
# endif /* HAVE_PTHREAD_H */
if (stat(filename, &(dp->entry.fileinfo)))
{
- DEBUG_printf((" stat() failed for \"%s\" - %s...\n", filename,
+ DEBUG_printf(("3cupsDirRead: stat() failed for \"%s\" - %s...", filename,
strerror(errno)));
continue;
}
/*
* 'cupsDirRewind()' - Rewind to the start of the directory.
+ *
+ * @since CUPS 1.2/OS X 10.5@
*/
void
-cupsDirRewind(cups_dir_t *dp) /* I - Directory */
+cupsDirRewind(cups_dir_t *dp) /* I - Directory pointer */
{
- DEBUG_printf(("cupsDirRewind(dp=%p)\n", dp));
+ DEBUG_printf(("cupsDirRewind(dp=%p)", dp));
/*
* Range check input...