Home

ftsclose

fts_close is a C library function used to finish a directory tree traversal that was started with fts_open. It is part of the File Traversal System (FTS) API, which provides facilities for walking directory hierarchies in a controlled manner. The function is defined in <fts.h> and is available on BSD-derived systems and in GNU libc on Linux.

Prototype: int fts_close(FTS *ftsp); ftsp is the pointer returned by fts_open.

What it does: fts_close releases the resources allocated for the traversal, including memory and any open directory

Return value: On success, fts_close returns 0. On error, it returns -1 and sets errno to indicate

Usage notes: Typical usage involves calling fts_open to obtain an FTS handle, processing entries with fts_read

Common considerations: The FTS interface is POSIX-like but originates from BSD; availability can vary by system.

See also: fts_open, fts_read, fts_children.

streams
associated
with
the
FTS
object.
It
does
not
modify
the
filesystem
or
delete
files.
The
function
should
be
called
after
the
traversal
is
complete,
even
if
you
stopped
early
due
to
an
error
during
processing.
the
failure.
(and
possibly
inspecting
fts_info
or
fts_children),
and
finally
calling
fts_close
to
free
resources.
If
fts_open
fails,
ftsp
is
NULL
and
fts_close
must
not
be
called.
If
errors
occur
during
traversal,
errno
may
be
set;
however,
you
should
still
call
fts_close
to
ensure
proper
resource
cleanup.
Correct
usage
centers
on
pairing
fts_open
with
a
subsequent
fts_close
and
handling
errors
from
both
fts_read
and
fts_close
where
appropriate.