VLC  4.0.0-dev
Functions
Collaboration diagram for File descriptors:

Functions

VLC_EXPORT int vlc_open (const char *filename, int flags,...)
 Opens a system file handle. More...
 
VLC_EXPORT int vlc_openat (int fd, const char *filename, int flags,...)
 Opens a system file handle relative to an existing directory handle. More...
 
VLC_EXPORT int vlc_mkstemp (char *)
 
VLC_EXPORT int vlc_dup (int oldfd)
 Duplicates a file descriptor. More...
 
VLC_EXPORT int vlc_dup2 (int oldfd, int newfd)
 Replaces a file descriptor. More...
 
VLC_EXPORT int vlc_pipe (int[2])
 Creates a pipe (see "man pipe" for further reference). More...
 
VLC_EXPORT int vlc_memfd (void)
 Creates an anonymous regular file descriptor, i.e. More...
 
VLC_EXPORT ssize_t vlc_write (int, const void *, size_t)
 Writes data to a file descriptor. More...
 
VLC_EXPORT ssize_t vlc_writev (int, const struct iovec *, int)
 Writes data from an iovec structure to a file descriptor. More...
 
VLC_EXPORT int vlc_close (int fd)
 Closes a file descriptor. More...
 

Detailed Description

Function Documentation

◆ vlc_close()

VLC_EXPORT int vlc_close ( int  fd)

Closes a file descriptor.

This closes a file descriptor. If this is a last file descriptor for the underlying open file, the file is closed too; the exact semantics depend on the type of file.

Note
The file descriptor is always closed when the function returns, even if the function returns an error. The sole exception is if the file descriptor was not currently valid, and thus cannot be closed (errno will then be set to EBADF).
Parameters
fdfile descriptor
Returns
Normally, zero is returned. If an I/O error is detected before or while closing, the function may return -1. Such an error is unrecoverable since the descriptor is closed.

A nul return value does not necessarily imply that all pending I/O succeeded, since I/O might still occur asynchronously afterwards.

◆ vlc_dup()

VLC_EXPORT int vlc_dup ( int  oldfd)

Duplicates a file descriptor.

Parameters
oldfdfile descriptor to duplicate
Note
Contrary to standard dup(), the new file descriptor has the close-on-exec descriptor flag preset.
Returns
a new file descriptor, -1 (see errno)

References likely.

Referenced by vlc_memfd().

◆ vlc_dup2()

VLC_EXPORT int vlc_dup2 ( int  oldfd,
int  newfd 
)

Replaces a file descriptor.

This function duplicates a file descriptor to a specified file descriptor. This is primarily used to atomically replace a described file.

Parameters
oldfdsource file descriptor to copy
newfddestination file descriptor to replace
Note
Contrary to standard dup2(), the new file descriptor has the close-on-exec descriptor flag preset.
Return values
newfdsuccess
-1failure (see errno)

References vlc_cloexec().

◆ vlc_memfd()

VLC_EXPORT int vlc_memfd ( void  )

Creates an anonymous regular file descriptor, i.e.

a descriptor for a temporary file.

The file is initially empty. The storage space is automatically reclaimed when all file descriptors referencing it are closed.

The new file descriptor has the close-on-exec flag preset.

Returns
a file descriptor on success, -1 on error (see errno)

References vlc_dup(), and vlc_mkstemp().

Referenced by picture_Allocate().

◆ vlc_mkstemp()

VLC_EXPORT int vlc_mkstemp ( char *  )

◆ vlc_open()

VLC_EXPORT int vlc_open ( const char *  filename,
int  flags,
  ... 
)

Opens a system file handle.

Parameters
filenamefile path to open (with UTF-8 encoding)
flagsopen() flags, see the C library open() documentation
Returns
a file handle on success, -1 on error (see errno).
Note
Contrary to standard open(), this function returns a file handle with the close-on-exec flag preset.

References ToLocaleDup, and widen_path().

Referenced by block_FilePath(), config_SaveConfigFile(), vlc_fopen(), vlc_mkstemp(), and vlc_rand_init().

◆ vlc_openat()

VLC_EXPORT int vlc_openat ( int  fd,
const char *  filename,
int  flags,
  ... 
)

Opens a system file handle relative to an existing directory handle.

Parameters
dirdirectory file descriptor
filenamefile path to open (with UTF-8 encoding)
flagsopen() flags, see the C library open() documentation
Returns
a file handle on success, -1 on error (see errno).
Note
Contrary to standard open(), this function returns a file handle with the close-on-exec flag preset.

◆ vlc_pipe()

VLC_EXPORT int vlc_pipe ( int  [2])

Creates a pipe (see "man pipe" for further reference).

The new file descriptors have the close-on-exec flag preset.

Returns
0 on success, -1 on error (see errno)

References vlc_cloexec(), and vlc_socketpair().

Referenced by vlc_getProxyUrl(), and vlc_poll_i11e_inner().

◆ vlc_write()

VLC_EXPORT ssize_t vlc_write ( int  ,
const void *  ,
size_t   
)

Writes data to a file descriptor.

Unlike write(), if EPIPE error occurs, this function does not generate a SIGPIPE signal.

Note
If the file descriptor is known to be neither a pipe/FIFO nor a connection-oriented socket, the normal write() should be used.

References vlc_writev().

◆ vlc_writev()

VLC_EXPORT ssize_t vlc_writev ( int  ,
const struct iovec *  ,
int   
)

Writes data from an iovec structure to a file descriptor.

Unlike writev(), if EPIPE error occurs, this function does not generate a SIGPIPE signal.

References count, and vlc_assert_unreachable.

Referenced by vlc_write().