OPENDIR(3) Linux Programmer's Manual OPENDIR(3)NAME
opendir - open a directory
SYNOPSIS
#include <sys/types.h>
#include <dirent.h>
DIR *opendir(const char *name);
DESCRIPTION
The opendir() function opens a directory stream corresponding to the directory name, and returns a pointer to the directory stream. The
stream is positioned at the first entry in the directory.
RETURN VALUE
The opendir() function returns a pointer to the directory stream or NULL if an error occurred.
ERRORS
EACCES Permission denied.
EMFILE Too many file descriptors in use by process.
ENFILE Too many files are currently open in the system.
ENOENT Directory does not exist, or name is an empty string.
ENOMEM Insufficient memory to complete the operation.
ENOTDIR
name is not a directory.
NOTES
The underlying file descriptor of the directory stream can be obtained using dirfd(3).
CONFORMING TO
SVID 3, POSIX, BSD 4.3
SEE ALSO open(2), closedir(3), dirfd(3), readdir(3), rewinddir(3), scandir(3), seekdir(3), telldir(3)
1995-06-11 OPENDIR(3)
Check Out this Related Man Page
OPENDIR(3) Linux Programmer's Manual OPENDIR(3)NAME
opendir, fdopendir - open a directory
SYNOPSIS
#include <sys/types.h>
#include <dirent.h>
DIR *opendir(const char *name);
DIR *fdopendir(int fd);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
fdopendir():
Since glibc 2.10:
_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
Before glibc 2.10:
_GNU_SOURCE
DESCRIPTION
The opendir() function opens a directory stream corresponding to the directory name, and returns a pointer to the directory stream. The
stream is positioned at the first entry in the directory.
The fdopendir() function is like opendir(), but returns a directory stream for the directory referred to by the open file descriptor fd.
After a successful call to fdopendir(), fd is used internally by the implementation, and should not otherwise be used by the application.
RETURN VALUE
The opendir() and fdopendir() functions return a pointer to the directory stream. On error, NULL is returned, and errno is set appropri-
ately.
ERRORS
EACCES Permission denied.
EBADF fd is not a valid file descriptor opened for reading.
EMFILE Too many file descriptors in use by process.
ENFILE Too many files are currently open in the system.
ENOENT Directory does not exist, or name is an empty string.
ENOMEM Insufficient memory to complete the operation.
ENOTDIR
name is not a directory.
VERSIONS
fdopendir() is available in glibc since version 2.4.
CONFORMING TO
opendir() is present on SVr4, 4.3BSD, and specified in POSIX.1-2001. fdopendir() is specified in POSIX.1-2008.
NOTES
The underlying file descriptor of the directory stream can be obtained using dirfd(3).
The opendir() function sets the close-on-exec flag for the file descriptor underlying the DIR *. The fdopendir() function leaves the set-
ting of the close-on-exec flag unchanged for the file descriptor, fd. POSIX.1-200x leaves it unspecified whether a successful call to
fdopendir() will set the close-on-exec flag for the file descriptor, fd.
SEE ALSO open(2), closedir(3), dirfd(3), readdir(3), rewinddir(3), scandir(3), seekdir(3), telldir(3)COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
GNU 2010-06-20 OPENDIR(3)
hi
i got in this way
DIR *dd;
dd = opendir("/root/ramesh/");
.....
then now i have problem
how can i convert a string to hexadecimals
ex: ram/es:h
show me the way
thank you for your feedback
ramesh (4 Replies)
Gday all
In a program I am designing, I am using opendir() to test whether entries under a certain directory are sub-directories or not. This method works fine for the directory itself (.) and the parent directory (..), however it does not work for any sub-directories I manually create.
i.e.... (5 Replies)
I have a question about transferring a directory to the toolman. I have a directory called assn3 that contains two txt files and one empty directory and I want to transfer the assn3 to my my tooman account. Every time I try to transfer the file it says that the assn3 is not a regular file! what... (3 Replies)
while starting apache i'm getting this error
(13)Permission denied: make_sock: could not bind to address :80
no listening sockets available, shutting down
Unable to open logs
Plz guide me to resolve this issue.. (2 Replies)
I'm currently studying for my exam, and is practicing with sample exam questions.
However there is a question asking "Name THREE UNIX Directory system calls" and the answer given is "opendir, closedir and readdir", however the next question ask "Why is a write directory system call not included... (1 Reply)
I am opening a text file using open() system call in O_RDONLY mode.
open() returns me a valid handler but also sets errno to 13 i.e. EACCES(Permission denied).
Question is when open() is returning a valid handler then why does it sets the errno?
Should not errno be set only in case of error... (10 Replies)