Functions

vlc_fs.h File Reference

Those functions convert file paths from UTF-8 to the system-specific encoding (especially UTF-16 on Windows). More...

Include dependency graph for vlc_fs.h:

Go to the source code of this file.

Functions

VLC_API int vlc_open (const char *filename, int flags,...) VLC_USED
 Opens a system file handle.
VLC_API FILE * vlc_fopen (const char *filename, const char *mode) VLC_USED
 Opens a FILE pointer.
VLC_API int vlc_openat (int fd, const char *filename, int flags,...) VLC_USED
 Opens a system file handle relative to an existing directory handle.
VLC_API DIR * vlc_opendir (const char *dirname) VLC_USED
 Opens a DIR pointer.
VLC_API char * vlc_readdir (DIR *dir) VLC_USED
 Reads the next file name from an open directory.
VLC_API int vlc_loaddir (DIR *dir, char ***namelist, int(*select)(const char *), int(*compar)(const char **, const char **))
 Does the same as vlc_scandir(), but takes an open directory pointer instead of a directory path.
VLC_API int vlc_scandir (const char *dirname, char ***namelist, int(*select)(const char *), int(*compar)(const char **, const char **))
 Selects file entries from a directory, as GNU C scandir().
VLC_API int vlc_mkdir (const char *filename, mode_t mode)
 Creates a directory using UTF-8 paths.
VLC_API int vlc_unlink (const char *filename)
 Removes a file.
VLC_API int vlc_rename (const char *oldpath, const char *newpath)
 Moves a file atomically.
VLC_API char * vlc_getcwd (void) VLC_USED
 Determines the current working directory.
VLC_API int vlc_stat (const char *filename, struct stat *buf)
 Finds file/inode information, as stat().
VLC_API int vlc_lstat (const char *filename, struct stat *buf)
 Finds file/inode information, as lstat().
VLC_API int vlc_mkstemp (char *)
VLC_API int vlc_dup (int)
 Duplicates a file descriptor.
VLC_API int vlc_pipe (int[2])
 Creates a pipe (see "man pipe" for further reference).

Detailed Description

Those functions convert file paths from UTF-8 to the system-specific encoding (especially UTF-16 on Windows).

Also, they always mark file descriptor with the close-on-exec flag.


Function Documentation

VLC_API 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.

VLC_API FILE* vlc_fopen ( const char *  filename,
const char *  mode 
)

Opens a FILE pointer.

Parameters:
filename file path, using UTF-8 encoding
mode fopen file open mode
Returns:
NULL on error, an open FILE pointer on success.

References vlc_open().

Referenced by ACL_LoadFile(), config_OpenConfigFile(), ImageWriteUrl(), libvlc_InternalInit(), playlist_Export(), playlist_SaveArt(), TsStorageNew(), and vout_snapshot_SaveImage().

VLC_API char* vlc_getcwd ( void   ) 

Determines the current working directory.

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

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

Referenced by make_URI().

VLC_API int vlc_loaddir ( DIR *  dir,
char ***  namelist,
int(*)(const char *)  select,
int(*)(const char **, const char **)  compar 
)

Does the same as vlc_scandir(), but takes an open directory pointer instead of a directory path.

References unlikely, and vlc_readdir().

Referenced by vlc_scandir().

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

Finds file/inode information, as lstat().

Consider using fstat() instead, if possible.

Parameters:
filename UTF-8 file path

References vlc_stat(), and vlc_statEx().

VLC_API int vlc_mkdir ( const char *  dirname,
mode_t  mode 
)

Creates a directory using UTF-8 paths.

Parameters:
dirname a UTF-8 string with the name of the directory that you want to create.
mode directory permissions
Returns:
0 on success, -1 on error (see errno).

References LocaleFree(), ToLocale(), unlikely, and widen_path().

Referenced by ArtCacheCreateDir(), config_CreateDir(), and GetTmpPath().

VLC_API int vlc_mkstemp ( char *   ) 

References vlc_open(), and vlc_rand_bytes().

Referenced by GetTmpFile().

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

Opens a system file handle.

Parameters:
filename file path to open (with UTF-8 encoding)
flags open() 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.

References ap, LocaleFree(), ToLocale(), va_end(), va_start(), and widen_path().

Referenced by SaveConfigFile(), vlc_fopen(), vlc_mkstemp(), and vlc_rand_init().

VLC_API int vlc_openat ( int  dir,
const char *  filename,
int  flags,
  ... 
)

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

Parameters:
dir directory file descriptor
filename file path to open (with UTF-8 encoding)
flags open() 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.

References ap, LocaleFree(), ToLocale(), va_end(), and va_start().

VLC_API DIR* vlc_opendir ( const char *  dirname  ) 

Opens a DIR pointer.

Parameters:
dirname UTF-8 representation of the directory name
Returns:
a pointer to the DIR struct, or NULL in case of error. Release with standard closedir().

References vlc_DIR::drives, vlc_DIR::insert_dot_dot, LocaleFree(), ToLocale(), vlc_DIR::u, unlikely, vlc_DIR::wdir, and widen_path().

Referenced by input_CreateFilename(), playlist_FindArtInCache(), subtitles_Detect(), vlc_scandir(), and vout_snapshot_SaveImage().

VLC_API int vlc_pipe ( int  [2]  ) 

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

Referenced by vlc_object_waitpipe().

VLC_API char* vlc_readdir ( DIR *  dir  ) 

Reads the next file name from an open directory.

Parameters:
dir The 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 asprintf(), dirfd(), vlc_DIR::drives, FromCharset(), FromLocaleDup(), vlc_DIR::insert_dot_dot, strdup(), vlc_DIR::u, unlikely, and vlc_DIR::wdir.

Referenced by playlist_FindArtInCache(), subtitles_Detect(), and vlc_loaddir().

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

Moves a file atomically.

This only works within a single file system.

Parameters:
oldpath path to the file before the move
newpath intended 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

References LocaleFree(), ToLocale(), and widen_path().

Referenced by SaveConfigFile().

VLC_API int vlc_scandir ( const char *  dirname,
char ***  namelist,
int(*)(const char *)  select,
int(*)(const char **, const char **)  compar 
)

Selects file entries from a directory, as GNU C scandir().

Parameters:
dirname UTF-8 diretory path
pointer [OUT] pointer set, on successful completion, to the address of a table of UTF-8 filenames. All filenames must be freed with free(). The table itself must be freed with free() as well.
Returns:
How many file names were selected (possibly 0), or -1 in case of error.

References vlc_loaddir(), and vlc_opendir().

VLC_API int vlc_stat ( const char *  filename,
struct stat *  buf 
)

Finds file/inode information, as stat().

Consider using fstat() instead, if possible.

Parameters:
filename UTF-8 file path

References static_assert, vlc_statEx(), and widen_path().

Referenced by GetTmpPath(), InputGetExtraFilesPattern(), playlist_MLLoad(), playlist_SaveArt(), SubtitleAdd(), subtitles_Detect(), vlc_lstat(), and vout_snapshot_SaveImage().

VLC_API int vlc_unlink ( const char *  filename  ) 

Removes a file.

Parameters:
filename a 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

References LocaleFree(), ToLocale(), unlikely, and widen_path().

Referenced by SaveConfigFile(), and TsStorageDelete().

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines