vlc_fs.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_fs.h: File system helpers
00003  *****************************************************************************
00004  * Copyright © 2006-2010 Rémi Denis-Courmont
00005  *
00006  * This program is free software; you can redistribute it and/or modify it
00007  * under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 2.1 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00019  *****************************************************************************/
00020 
00021 #ifndef VLC_FS_H
00022 #define VLC_FS_H 1
00023 
00024 /**
00025  * \file
00026  * Those functions convert file paths from UTF-8 to the system-specific
00027  * encoding (especially UTF-16 on Windows). Also, they always mark file
00028  * descriptor with the close-on-exec flag.
00029  */
00030 
00031 #include <sys/types.h>
00032 #include <dirent.h>
00033 
00034 VLC_API int vlc_open( const char *filename, int flags, ... ) VLC_USED;
00035 VLC_API FILE * vlc_fopen( const char *filename, const char *mode ) VLC_USED;
00036 VLC_API int vlc_openat( int fd, const char *filename, int flags, ... ) VLC_USED;
00037 
00038 VLC_API DIR * vlc_opendir( const char *dirname ) VLC_USED;
00039 VLC_API char * vlc_readdir( DIR *dir ) VLC_USED;
00040 VLC_API int vlc_loaddir( DIR *dir, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) );
00041 VLC_API int vlc_scandir( const char *dirname, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) );
00042 VLC_API int vlc_mkdir( const char *filename, mode_t mode );
00043 
00044 VLC_API int vlc_unlink( const char *filename );
00045 VLC_API int vlc_rename( const char *oldpath, const char *newpath );
00046 VLC_API char *vlc_getcwd( void ) VLC_USED;
00047 
00048 #if defined( WIN32 )
00049 static inline int vlc_closedir( DIR *dir )
00050 {
00051     _WDIR *wdir = *(_WDIR **)dir;
00052     free( dir );
00053     return wdir ? _wclosedir( wdir ) : 0;
00054 }
00055 # undef closedir
00056 # define closedir vlc_closedir
00057 
00058 static inline void vlc_rewinddir( DIR *dir )
00059 {
00060     _WDIR *wdir = *(_WDIR **)dir;
00061 
00062     _wrewinddir( wdir );
00063 }
00064 # undef rewinddir
00065 # define rewinddir vlc_rewinddir
00066 
00067 # include <sys/stat.h>
00068 # ifndef UNDER_CE
00069 #  ifndef stat
00070 #   define stat _stati64
00071 #  endif
00072 #  ifndef fstat
00073 #   define fstat _fstati64
00074 #  endif
00075 # endif
00076 #endif
00077 
00078 struct stat;
00079 
00080 VLC_API int vlc_stat( const char *filename, struct stat *buf );
00081 VLC_API int vlc_lstat( const char *filename, struct stat *buf );
00082 
00083 VLC_API int vlc_mkstemp( char * );
00084 
00085 VLC_API int vlc_dup( int );
00086 VLC_API int vlc_pipe( int[2] );
00087 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines