bluray: factorize blurayReleaseVout()
[vlc.git] / include / vlc_fs.h
blob83d892e8ca2afee6fd44216d5c108ce578f9bcd6
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 * The functions in this file help with using low-level Unix-style file
27 * descriptors, BSD sockets and directories. In general, they retain the
28 * prototype and most semantics from their respective standard equivalents.
29 * However, there are a few differences:
30 * - On Windows, file path arguments are expected in UTF-8 format.
31 * They are converted to UTF-16 internally, thus enabling access to paths
32 * outside of the local Windows ANSI code page.
33 * - On POSIX systems, file descriptors are created with the close-on-exec
34 * flag set (atomically where possible), so that they do not leak to
35 * child process after fork-and-exec.
36 * - vlc_scandir(), inspired by GNU scandir(), passes file names rather than
37 * dirent structure pointers to its callbacks.
38 * - vlc_accept() takes an extra boolean for nonblocking mode (compare with
39 * the flags parameter in POSIX.next accept4()).
40 * - Writing functions do not emit a SIGPIPE signal in case of broken pipe.
43 #include <sys/types.h>
44 #include <dirent.h>
46 VLC_API int vlc_open( const char *filename, int flags, ... ) VLC_USED;
47 VLC_API FILE * vlc_fopen( const char *filename, const char *mode ) VLC_USED;
48 VLC_API int vlc_openat( int fd, const char *filename, int flags, ... ) VLC_USED;
50 VLC_API DIR * vlc_opendir( const char *dirname ) VLC_USED;
51 VLC_API char * vlc_readdir( DIR *dir ) VLC_USED;
52 VLC_API int vlc_loaddir( DIR *dir, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) );
53 VLC_API int vlc_scandir( const char *dirname, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) );
54 VLC_API int vlc_mkdir( const char *filename, mode_t mode );
56 VLC_API int vlc_unlink( const char *filename );
57 VLC_API int vlc_rename( const char *oldpath, const char *newpath );
58 VLC_API char *vlc_getcwd( void ) VLC_USED;
60 #if defined( _WIN32 )
61 typedef struct vlc_DIR
63 _WDIR *wdir; /* MUST be first, see <vlc_fs.h> */
64 char *entry;
65 union
67 DWORD drives;
68 bool insert_dot_dot;
69 } u;
70 } vlc_DIR;
72 static inline int vlc_closedir( DIR *dir )
74 vlc_DIR *vdir = (vlc_DIR *)dir;
75 _WDIR *wdir = vdir->wdir;
77 free( vdir->entry );
78 free( vdir );
79 return (wdir != NULL) ? _wclosedir( wdir ) : 0;
81 # undef closedir
82 # define closedir vlc_closedir
84 static inline void vlc_rewinddir( DIR *dir )
86 _WDIR *wdir = *(_WDIR **)dir;
88 _wrewinddir( wdir );
90 # undef rewinddir
91 # define rewinddir vlc_rewinddir
93 # include <sys/stat.h>
94 # ifndef stat
95 # define stat _stati64
96 # endif
97 # ifndef fstat
98 # define fstat _fstati64
99 # endif
100 # ifndef _MSC_VER
101 # undef lseek
102 # define lseek _lseeki64
103 # endif
104 #endif
106 #ifdef __ANDROID__
107 # define lseek lseek64
108 #endif
110 struct stat;
111 struct iovec;
113 VLC_API int vlc_stat( const char *filename, struct stat *buf );
114 VLC_API int vlc_lstat( const char *filename, struct stat *buf );
116 VLC_API int vlc_mkstemp( char * );
118 VLC_API int vlc_dup( int );
119 VLC_API int vlc_pipe( int[2] );
120 VLC_API ssize_t vlc_write( int, const void *, size_t );
121 VLC_API ssize_t vlc_writev( int, const struct iovec *, int );
122 #endif