png: reduce encoding time
[vlc.git] / include / vlc_fs.h
blob533aa9bc91d51d0dbad6d79118a0ed8de3b3506e
1 /*****************************************************************************
2 * vlc_fs.h: File system helpers
3 *****************************************************************************
4 * Copyright © 2006-2010 Rémi Denis-Courmont
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 #ifndef VLC_FS_H
22 #define VLC_FS_H 1
24 /**
25 * \file
26 * Those functions convert file paths from UTF-8 to the system-specific
27 * encoding (especially UTF-16 on Windows). Also, they always mark file
28 * descriptor with the close-on-exec flag.
31 #include <sys/types.h>
32 #include <dirent.h>
34 VLC_API int vlc_open( const char *filename, int flags, ... ) VLC_USED;
35 VLC_API FILE * vlc_fopen( const char *filename, const char *mode ) VLC_USED;
36 VLC_API int vlc_openat( int fd, const char *filename, int flags, ... ) VLC_USED;
38 VLC_API DIR * vlc_opendir( const char *dirname ) VLC_USED;
39 VLC_API char * vlc_readdir( DIR *dir ) VLC_USED;
40 VLC_API int vlc_loaddir( DIR *dir, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) );
41 VLC_API int vlc_scandir( const char *dirname, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) );
42 VLC_API int vlc_mkdir( const char *filename, mode_t mode );
44 VLC_API int vlc_unlink( const char *filename );
45 VLC_API int vlc_rename( const char *oldpath, const char *newpath );
46 VLC_API char *vlc_getcwd( void ) VLC_USED;
48 #if defined( _WIN32 )
49 typedef struct vlc_DIR
51 _WDIR *wdir; /* MUST be first, see <vlc_fs.h> */
52 char *entry;
53 union
55 DWORD drives;
56 bool insert_dot_dot;
57 } u;
58 } vlc_DIR;
60 static inline int vlc_closedir( DIR *dir )
62 vlc_DIR *vdir = (vlc_DIR *)dir;
63 _WDIR *wdir = vdir->wdir;
65 free( vdir->entry );
66 free( vdir );
67 return (wdir != NULL) ? _wclosedir( wdir ) : 0;
69 # undef closedir
70 # define closedir vlc_closedir
72 static inline void vlc_rewinddir( DIR *dir )
74 _WDIR *wdir = *(_WDIR **)dir;
76 _wrewinddir( wdir );
78 # undef rewinddir
79 # define rewinddir vlc_rewinddir
81 # include <sys/stat.h>
82 # ifndef stat
83 # define stat _stati64
84 # endif
85 # ifndef fstat
86 # define fstat _fstati64
87 # endif
88 # ifndef _MSC_VER
89 # undef lseek
90 # define lseek _lseeki64
91 # endif
92 #endif
94 #ifdef __ANDROID__
95 # define lseek lseek64
96 #endif
98 struct stat;
100 VLC_API int vlc_stat( const char *filename, struct stat *buf );
101 VLC_API int vlc_lstat( const char *filename, struct stat *buf );
103 VLC_API int vlc_mkstemp( char * );
105 VLC_API int vlc_dup( int );
106 VLC_API int vlc_pipe( int[2] );
107 #endif