VLC  4.0.0-dev
Functions
Collaboration diagram for Directories:

Functions

VLC_EXPORT DIR * vlc_opendir (const char *dirname)
 Opens a DIR pointer. More...
 
const VLC_EXPORT char * vlc_readdir (DIR *dir)
 Reads the next file name from an open directory. More...
 
VLC_EXPORT 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. More...
 
VLC_EXPORT 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(). More...
 
VLC_EXPORT int vlc_mkdir (const char *dirname, mode_t mode)
 Creates a directory. More...
 
VLC_EXPORT char * vlc_getcwd (void)
 Determines the current working directory. More...
 

Detailed Description

Function Documentation

◆ vlc_getcwd()

VLC_EXPORT char* vlc_getcwd ( void  )

Determines the current working directory.

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

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

Referenced by vlc_path2uri().

◆ vlc_loaddir()

VLC_EXPORT 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 compar, compar_void(), dummy_select(), likely, strdup(), unlikely, vlc_qsort(), and vlc_readdir().

Referenced by vlc_scandir().

◆ vlc_mkdir()

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

Creates a directory.

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

References ToLocaleDup, unlikely, and widen_path().

Referenced by ArtCacheCreateDir(), config_CreateDir(), config_GetHomeDir(), and GetTmpFile().

◆ vlc_opendir()

VLC_EXPORT 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().

References ToLocaleDup, unlikely, and widen_path().

Referenced by input_FindArtInCache(), subtitles_Detect(), and vlc_scandir().

◆ vlc_readdir()

const VLC_EXPORT char* vlc_readdir ( DIR *  dir)

Reads the next file name from an open directory.

Parameters
dirdirectory handle as returned by vlc_opendir() (must not be used by another thread concurrently)
Returns
a UTF-8 string of the directory entry. The string is valid until the next call to vlc_readdir() or closedir() on the handle. 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(), FromCharset(), strdup(), and unlikely.

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

◆ vlc_scandir()

VLC_EXPORT 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
dirnameUTF-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 compar, vlc_loaddir(), and vlc_opendir().