dir.c revision b05363a2b9b01acaa767a5a2f4a2936c276140ac
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * Copyright (C) 1999 Internet Software Consortium.
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * copyright notice and this permission notice appear in all copies.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
1d32b1df372d6be6bac6450739b9e5ea23819995Evan Hunt * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
30a60d2aff0ec1810262a8b8efc532e28b32bd57Evan Hunt/* $Id: dir.c,v 1.3 1999/09/28 03:37:36 tale Exp $ */
30a60d2aff0ec1810262a8b8efc532e28b32bd57Evan Hunt/* Principal Authors: DCL */
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * Allocate workspace and open directory stream. If either one fails,
222d38735f97f771054e223b03f84c5858252332Evan Hunt * NULL will be returned.
222d38735f97f771054e223b03f84c5858252332Evan Huntisc_dir_open(const char *dirname, isc_dir_t *dir) {
28002bd7cb4baa0eab9f47e1e51069c5ea7ea5d4Andreas Gustafsson * Open stream.
c634c94d673f1bab17e7f65d332f989b683e712cDavid Lawrence * Return previously retrieved file or get next one. Unix's dirent has
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * separate open and read functions, but the Win32 and DOS interfaces open
222d38735f97f771054e223b03f84c5858252332Evan Hunt * the dir stream and reads the first file in one operation.
222d38735f97f771054e223b03f84c5858252332Evan Hunt * Fetch next file in directory.
9069215eac23e32f4ef1c8e44ad7ff2865cfcdacEvan Hunt * Make sure that the space for the name is long enough.
9069215eac23e32f4ef1c8e44ad7ff2865cfcdacEvan Hunt INSIST(sizeof(dir->entry.name) > strlen(entry->d_name));
9069215eac23e32f4ef1c8e44ad7ff2865cfcdacEvan Hunt * Some dirents have d_namlen, but it is not portable.
222d38735f97f771054e223b03f84c5858252332Evan Hunt * Close directory stream.
b5b934a0bb46aded1552a17473652b5a7f4a3274Evan Hunt * Reposition directory stream at start.