---
name: "explain_filename"
section: "3"
platform: "linux"
package: "libexplain-dev"
version: "1.4.D001-16"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/explain_filename"
---

# explain\_filename(3)

obtain filename from file descriptor

## NAME

explain\_filename\_from\_fildes - obtain filename from file descriptor

## SYNOPSIS

\#include \<libexplain/filename.h\>

int explain\_filename\_from\_fildes(int fildes, char \*data, size\_t data\_size);

int explain\_filename\_from\_stream(FILE \*stream, char \*data, size\_t data\_size);

## DESCRIPTION

The *explain\_filename\_from\_fildes* function may be used to obtain the name of the file associated with the file descriptor.

The *explain\_filename\_from\_stream* function may be used to obtain the name of the file associated with a file stream.

The filename is returned in the array pointed to by *data*. The filename will always be NUL terminated. If the returned filename is longer than *data\_size*, it will be silently truncated; a size of at least (PATH\_MAX + 1) is suggested.

On success, returns zero. If the file name cannot be determined, returns -1 (but does **not** set *errno*.)

## COPYRIGHT

libexplain version 1.4\
 Copyright (C) 2012 Peter Miller

## AUTHOR

Written by Peter Miller \<pmiller@opensource.org.au\>
