VLC  2.1.0-git
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
filesystem.c File Reference
Include dependency graph for filesystem.c:

Macros

#define lstat(a, b)   stat(a, b)

Functions

int vlc_open (const char *filename, int flags,...)
 Opens a system file handle.
int vlc_openat (int dir, const char *filename, int flags,...)
 Opens a system file handle relative to an existing directory handle.
int vlc_mkdir (const char *dirname, mode_t mode)
 Creates a directory using UTF-8 paths.
DIR * vlc_opendir (const char *dirname)
 Opens a DIR pointer.
char * vlc_readdir (DIR *dir)
 Reads the next file name from an open directory.
int vlc_stat (const char *filename, struct stat *buf)
 Finds file/inode information, as stat().
int vlc_lstat (const char *filename, struct stat *buf)
 Finds file/inode information, as lstat().
int vlc_unlink (const char *filename)
 Removes a file.
int vlc_rename (const char *oldpath, const char *newpath)
 Moves a file atomically.
char * vlc_getcwd (void)
 Determines the current working directory.
int vlc_dup (int oldfd)
 Duplicates a file descriptor.
int vlc_pipe (int fds[2])
 Creates a pipe (see "man pipe" for further reference).
int vlc_socket (int pf, int type, int proto, bool nonblock)
 Creates a socket file descriptor.
int vlc_accept (int lfd, struct sockaddr *addr, socklen_t *alen, bool nonblock)
 Accepts an inbound connection request on a listening socket.

Macro Definition Documentation

#define lstat (   a,
 
)    stat(a, b)

Referenced by vlc_lstat(), and vlc_statEx().

Function Documentation

int vlc_accept ( int  lfd,
struct sockaddr *  addr,
socklen_t *  alen,
bool  nonblock 
)

Accepts an inbound connection request on a listening socket.

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

Parameters
lfdlistening socket file descriptor
addrpointer to the peer address or NULL [OUT]
alenpointer to the length of the peer address or NULL [OUT]
nonblockwhether to put the new socket in non-blocking mode
Returns
a new file descriptor, or -1 on error.
int vlc_dup ( int  oldfd)

Duplicates a file descriptor.

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

Returns
a new file descriptor or -1

References likely, and unlikely.

char* vlc_getcwd ( void  )

Determines the current working directory.

Returns
the current working directory (must be free()'d) or NULL on error

References getenv(), strdup(), and unlikely.

int vlc_lstat ( const char *  filename,
struct stat *  buf 
)

Finds file/inode information, as lstat().

Consider using fstat() instead, if possible.

Parameters
filenameUTF-8 file path

References lstat.

int vlc_mkdir ( const char *  dirname,
mode_t  mode 
)

Creates a directory using UTF-8 paths.

Parameters
dirnamea UTF-8 string with the name of the directory that you want to create.
modedirectory permissions
Returns
0 on success, -1 on error (see errno).
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 file handles with the close-on-exec flag enabled.
int vlc_openat ( int  dir,
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 file handles with the close-on-exec flag enabled.
DIR* vlc_opendir ( const char *  dirname)

Opens a DIR pointer.

Parameters
dirnameUTF-8 representation of the directory name
Returns
a pointer to the DIR struct, or NULL in case of error. Release with standard closedir().
int vlc_pipe ( int  fds[2])

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

char* vlc_readdir ( DIR *  dir)

Reads the next file name from an open directory.

Parameters
dirThe directory that is being read
Returns
a UTF-8 string of the directory entry. Use free() to release it. If there are no more entries in the directory, NULL is returned. If an error occurs, errno is set and NULL is returned.

References dirfd(), strdup(), and unlikely.

int vlc_rename ( const char *  oldpath,
const char *  newpath 
)

Moves a file atomically.

This only works within a single file system.

Parameters
oldpathpath to the file before the move
newpathintended path to the file after the move
Returns
A 0 return value indicates success. A -1 return value indicates an error, and an error code is stored in errno
int vlc_socket ( int  pf,
int  type,
int  proto,
bool  nonblock 
)

Creates a socket file descriptor.

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

Parameters
pfprotocol family
typesocket type
protonetwork protocol
nonblocktrue to create a non-blocking socket
Returns
a new file descriptor or -1
int vlc_stat ( const char *  filename,
struct stat *  buf 
)

Finds file/inode information, as stat().

Consider using fstat() instead, if possible.

Parameters
filenameUTF-8 file path
int vlc_unlink ( const char *  filename)

Removes a file.

Parameters
filenamea UTF-8 string with the name of the file you want to delete.
Returns
A 0 return value indicates success. A -1 return value indicates an error, and an error code is stored in errno