icon Top 9 categories map      RocketAware > man pages >

directory(3)

Tips: Browse or Search all pages for efficient awareness of more than 6000 of the most popular reusable and open source applications, functions, libraries, and FAQs.


The "RKT couplings" below include links to source code, updates, additional information, advice, FAQs, and overviews.


Home

Search all pages


Subjects

By activity
Professions, Sciences, Humanities, Business, ...

User Interface
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...

Text Strings
Conversions, tests, processing, manipulation,...

Math
Integer, Floating point, Matrix, Statistics, Boolean, ...

Processing
Algorithms, Memory, Process control, Debugging, ...

Stored Data
Data storage, Integrity, Encryption, Compression, ...

Communications
Networks, protocols, Interprocess, Remote, Client Server, ...

Hard World
Timing, Calendar and Clock, Audio, Video, Printer, Controls...

File System
Management, Filtering, File & Directory access, Viewers, ...

    

RocketLink!--> Man page versions: OpenBSD FreeBSD Others



DIRECTORY(3)              OpenBSD Programmer's Manual             DIRECTORY(3)

NAME
     opendir, readdir, telldir, seekdir, rewinddir, closedir, dirfd - directo-
     ry operations



SYNOPSIS
     #include <sys/types.h>
     #include <dirent.h>

     DIR *
     opendir(const char *filename);

     struct dirent *
     readdir(DIR *dirp);

     long
     telldir(const DIR *dirp);

     void
     seekdir(DIR *dirp, long loc);

     void
     rewinddir(DIR *dirp);

     int
     closedir(DIR *dirp);

     int
     dirfd(DIR *dirp);

DESCRIPTION
     The opendir() function opens the directory named by filename, associates
     a directory stream with it and returns a pointer to be used to identify
     the directory stream in subsequent operations.  A null pointer is re-
     turned if filename cannot be accessed, or if malloc(3) cannot allocate
     enough memory to hold the entire structure.

     The readdir() function returns a pointer to the next directory entry in
     the named directory stream dirp. It returns NULL upon reaching the end of
     the directory or detecting an invalid seekdir() operation.

     The telldir() function returns the current location associated with the
     named directory stream dirp.

     The seekdir() function sets the position of the next readdir() operation
     on the named directory stream dirp. The new position reverts to the one
     associated with the directory stream when the telldir() operation was
     performed.  Values returned by telldir() are good only for the lifetime
     of the DIR pointer, dirp, from which they are derived.  If the directory
     is closed and then reopened, the telldir() value may be invalidated due
     to undetected directory compaction.  It is safe to use a previous
     telldir() value immediately after a call to opendir() and before any
     calls to readdir().

     The rewinddir() function resets the position of the named directory
     stream dirp to the beginning of the directory.

     The closedir() function closes the named directory stream and frees the
     structure associated with the dirp pointer, returning 0 on success.  On
     failure, -1 is returned and the global variable errno is set to indicate
     the error.

     The dirfd() function returns the integer file descriptor associated with
     the named directory stream dirp (see open(2)).

EXAMPLES
     Sample code which searches a directory for entry ``name'' is:

           len = strlen(name);
           dirp = opendir(".");
           if (dirp) {
                   while ((dp = readdir(dirp)) != NULL)
                           if (dp->d_namlen == len && !strcmp(dp->d_name, name)) {
                                   (void)closedir(dirp);
                                   return FOUND;
                           }
                   (void)closedir(dirp);
           }
           return NOT_FOUND;

SEE ALSO
     close(2),  getdirentries(2),  lseek(2),  open(2),  dir(5)

HISTORY
     The opendir(), readdir(), telldir(), seekdir(), rewinddir(), closedir(),
     and dirfd() functions appeared in 4.2BSD.

OpenBSD 2.6                      June 4, 1993                                2

Source: OpenBSD 2.6 man pages. Copyright: Portions are copyrighted by BERKELEY
SOFTWARE DESIGN, INC., The Regents of the University of California, Massachusetts
Institute of Technology, Free Software Foundation, FreeBSD Inc., and others.



(Corrections, notes, and links courtesy of RocketAware.com)


[Detailed Topics]
FreeBSD Sources for directory(3) functions
OpenBSD sources for directory(3)


[Overview Topics]

Up to: Directory Access - Accessing directories of files, browsing, management, et al.


RocketLink!--> Man page versions: OpenBSD FreeBSD Others






Rapid-Links: Search | About | Comments | Submit Path: RocketAware > man pages > directory.3/
RocketAware.com is a service of Mib Software
Copyright 1999, Forrest J. Cavalier III. All Rights Reserved.
We welcome submissions and comments