Module dirent

Data Types

dirent()

dirent() = reference()

Directory reference.

dirname()

dirname() = filename()

Directory name.

dtype()

abstract datatype: dtype()

Indicates the file type.

device
This is a block or character device.
directory
This is a directory.
symlink
This is a symbolic link.
regular
This is a regular file.
other
This is a UNIX domain socket or named pipe (FIFO).
undefined
The file type could not be determined.

filename()

filename() = file:name()

File name.

posix_error()

abstract datatype: posix_error()

Common POSIX errors:

enoent
Directory does not exist, or Path is an empty string.
eacces
Permission denied.
emfile
The per-process limit on the number of open file descriptors has been reached.
enfile
The system-wide limit on the total number of open files has been reached.
enomem
Insufficient memory to complete the operation.
enotdir
Path is not a directory.

Function Index

controlling_process/2Set controlling affinity.
opendir/1Opens the given Path.
readdir/1Lists all files in DirRef, except files with raw names.
readdir_all/1Lists all files in DirRef, including files with raw names, returning also the file type.
readdir_raw/1Lists raw filenames in DirRef, returning also the file type.
readdir_type/1Lists all files in DirRef, except files with raw names, returning also the file type.

Function Details

controlling_process/2

controlling_process(DirRef, Pid) -> ok

Set controlling affinity.

Once created, DirRef is associated to the calling process and reading functions should be executed by the same process. If passing to another process is required, then this function should be called from the process owner, delegating control to another process indicated by Pid.

opendir/1

opendir(Path) -> DirRef | {error, Reason}

Opens the given Path. Returns {ok, DirRef} if successful, otherwise {error, Reason}.

readdir/1

readdir(DirRef) -> F | finished | {error, Reason}

Lists all files in DirRef, except files with raw names. Returns F while iterating over the directory or finished when done.

If the filename is a binary() with characters coded in ISO Latin-1 and the VM was started with parameter +fnue, the function returns {error, {no_translation, RawName}}.

If called by any other process than the current controlling process, {error, not_owner} is returned.

The names are not sorted.

readdir_all/1

readdir_all(DirRef) -> {F, Dtype} | finished | {error, Reason}

Lists all files in DirRef, including files with raw names, returning also the file type.

Returns {F, Dtype} or finished when done. Dtype can be used to avoid making a second call to file:read_file_info/1,2 if the filesystem has support to it in the system readdir. If the filesystem does not have support, Dtype will be always undefined.

If Unicode filename translation is in effect and the file system is transparent, filenames that cannot be interpreted as Unicode can be encountered, in which case F will represent a raw filename (that is, binary).

If called by any other process than the current controlling process, {error, not_owner} is returned.

The names are not sorted.

readdir_raw/1

readdir_raw(DirRef) -> {F, Dtype} | finished | {error, Reason}

Lists raw filenames in DirRef, returning also the file type.

No Unicode translation is made on the filename, and it is returned in raw format (binary).

Returns {F, Dtype} or finished when done. Dtype can be used to avoid making a second call to file:read_file_info/1,2 if the filesystem has support to it in the system readdir. If the filesystem does not have support, Dtype will be always undefined.

The names are not sorted.

readdir_type/1

readdir_type(DirRef) -> {F, Dtype} | finished | {error, Reason}

Lists all files in DirRef, except files with raw names, returning also the file type.

Returns {F, Dtype} or finished when done. Dtype can be used to avoid making a second call to file:read_file_info/1,2 if the filesystem has support to it in the system readdir. If the filesystem does not have support, Dtype will be always undefined.

If the filename is a binary() with characters coded in ISO Latin-1 and the VM was started with parameter +fnue, the function returns {error, {no_translation, RawName}}.

If called by any other process than the current controlling process, {error, not_owner} is returned.

The names are not sorted.


Generated by EDoc