Commit d601e4ed authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Split file path functions out of vlc_charset.h into vlc_fs.h

parent 0ce5cde7
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* charset.h: Unicode UTF-8 wrappers function * charset.h: Unicode UTF-8 wrappers function
***************************************************************************** *****************************************************************************
* Copyright (C) 2003-2005 the VideoLAN team * Copyright (C) 2003-2005 the VideoLAN team
* Copyright © 2005-2006 Rémi Denis-Courmont * Copyright © 2005-2010 Rémi Denis-Courmont
* $Id$ * $Id$
* *
* Author: Rémi Denis-Courmont <rem # videolan,org> * Author: Rémi Denis-Courmont <rem # videolan,org>
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
*/ */
#include <stdarg.h> #include <stdarg.h>
#include <sys/types.h>
#include <dirent.h>
VLC_EXPORT( void, LocaleFree, ( const char * ) ); VLC_EXPORT( void, LocaleFree, ( const char * ) );
VLC_EXPORT( char *, FromLocale, ( const char * ) LIBVLC_USED ); VLC_EXPORT( char *, FromLocale, ( const char * ) LIBVLC_USED );
...@@ -40,29 +38,9 @@ VLC_EXPORT( char *, FromLocaleDup, ( const char * ) LIBVLC_USED ); ...@@ -40,29 +38,9 @@ VLC_EXPORT( char *, FromLocaleDup, ( const char * ) LIBVLC_USED );
VLC_EXPORT( char *, ToLocale, ( const char * ) LIBVLC_USED ); VLC_EXPORT( char *, ToLocale, ( const char * ) LIBVLC_USED );
VLC_EXPORT( char *, ToLocaleDup, ( const char * ) LIBVLC_USED ); VLC_EXPORT( char *, ToLocaleDup, ( const char * ) LIBVLC_USED );
/* TODO: move all of this to "vlc_fs.h" or something like that */
VLC_EXPORT( int, utf8_open, ( const char *filename, int flags, ... ) LIBVLC_USED );
VLC_EXPORT( FILE *, utf8_fopen, ( const char *filename, const char *mode ) LIBVLC_USED );
VLC_EXPORT( DIR *, utf8_opendir, ( const char *dirname ) LIBVLC_USED );
VLC_EXPORT( char *, utf8_readdir, ( DIR *dir ) LIBVLC_USED );
VLC_EXPORT( int, utf8_loaddir, ( DIR *dir, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) ) );
VLC_EXPORT( int, utf8_scandir, ( const char *dirname, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) ) );
VLC_EXPORT( int, utf8_mkdir, ( const char *filename, mode_t mode ) );
VLC_EXPORT( int, utf8_unlink, ( const char *filename ) );
int utf8_rename( const char *, const char * );
#if defined( WIN32 ) && !defined( UNDER_CE )
# define stat _stati64
#endif
VLC_EXPORT( int, utf8_stat, ( const char *filename, struct stat *buf ) );
VLC_EXPORT( int, utf8_lstat, ( const char *filename, struct stat *buf ) );
VLC_EXPORT( int, utf8_vfprintf, ( FILE *stream, const char *fmt, va_list ap ) ); VLC_EXPORT( int, utf8_vfprintf, ( FILE *stream, const char *fmt, va_list ap ) );
VLC_EXPORT( int, utf8_fprintf, ( FILE *, const char *, ... ) LIBVLC_FORMAT( 2, 3 ) ); VLC_EXPORT( int, utf8_fprintf, ( FILE *, const char *, ... ) LIBVLC_FORMAT( 2, 3 ) );
VLC_EXPORT( int, utf8_mkstemp, ( char * ) );
VLC_EXPORT( char *, EnsureUTF8, ( char * ) ); VLC_EXPORT( char *, EnsureUTF8, ( char * ) );
VLC_EXPORT( const char *, IsUTF8, ( const char * ) LIBVLC_USED ); VLC_EXPORT( const char *, IsUTF8, ( const char * ) LIBVLC_USED );
......
/*****************************************************************************
* vlc_fs.h: File system helpers
*****************************************************************************
* Copyright © 2006-2010 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef VLC_FS_H
#define VLC_FS_H 1
/**
* \file
* 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.
*/
#include <sys/types.h>
#include <dirent.h>
VLC_EXPORT( int, utf8_open, ( const char *filename, int flags, ... ) LIBVLC_USED );
VLC_EXPORT( FILE *, utf8_fopen, ( const char *filename, const char *mode ) LIBVLC_USED );
VLC_EXPORT( DIR *, utf8_opendir, ( const char *dirname ) LIBVLC_USED );
VLC_EXPORT( char *, utf8_readdir, ( DIR *dir ) LIBVLC_USED );
VLC_EXPORT( int, utf8_loaddir, ( DIR *dir, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) ) );
VLC_EXPORT( int, utf8_scandir, ( const char *dirname, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) ) );
VLC_EXPORT( int, utf8_mkdir, ( const char *filename, mode_t mode ) );
VLC_EXPORT( int, utf8_unlink, ( const char *filename ) );
/* Not exported */
int utf8_rename( const char *, const char * );
#if defined( WIN32 ) && !defined( UNDER_CE )
# define stat _stati64
#endif
VLC_EXPORT( int, utf8_stat, ( const char *filename, struct stat *buf ) );
VLC_EXPORT( int, utf8_lstat, ( const char *filename, struct stat *buf ) );
VLC_EXPORT( int, utf8_mkstemp, ( char * ) );
#endif
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include <vlc_input.h> #include <vlc_input.h>
#include <vlc_access.h> #include <vlc_access.h>
#include <vlc_demux.h> #include <vlc_demux.h>
#include <vlc_charset.h> #include <vlc_fs.h>
#include <vlc_bits.h> #include <vlc_bits.h>
#include <assert.h> #include <assert.h>
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_input.h> #include <vlc_input.h>
#include <vlc_demux.h> #include <vlc_demux.h>
#include <vlc_charset.h> #include <vlc_fs.h>
#include <vlc_picture.h> #include <vlc_picture.h>
#ifdef HAVE_FCNTL_H #ifdef HAVE_FCNTL_H
......
...@@ -55,7 +55,7 @@ static inline int dirfd (DIR *dir) ...@@ -55,7 +55,7 @@ static inline int dirfd (DIR *dir)
} }
#endif #endif
#include <vlc_charset.h> #include <vlc_fs.h>
#include <vlc_url.h> #include <vlc_url.h>
#include <vlc_strings.h> #include <vlc_strings.h>
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <poll.h> #include <poll.h>
#include <vlc_charset.h> #include <vlc_fs.h>
/* DVB Card Drivers */ /* DVB Card Drivers */
#include <linux/dvb/version.h> #include <linux/dvb/version.h>
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <vlc_access.h> #include <vlc_access.h>
#include <vlc_demux.h> #include <vlc_demux.h>
#include <vlc_charset.h> #include <vlc_charset.h>
#include <vlc_fs.h>
#include <vlc_dialog.h> #include <vlc_dialog.h>
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
# define PathIsNetworkPathW(wpath) (! wcsncmp(wpath, L"\\\\", 2)) # define PathIsNetworkPathW(wpath) (! wcsncmp(wpath, L"\\\\", 2))
#endif #endif
#include <vlc_charset.h> #include <vlc_fs.h>
#include <vlc_url.h> #include <vlc_url.h>
struct access_sys_t struct access_sys_t
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#include <vlc_charset.h> #include <dirent.h>
int Open (vlc_object_t *); int Open (vlc_object_t *);
void Close (vlc_object_t *); void Close (vlc_object_t *);
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_access.h> #include <vlc_access.h>
#include <vlc_input.h> #include <vlc_input.h>
#include <vlc_charset.h> #include <vlc_fs.h>
#include <vlc_dialog.h> #include <vlc_dialog.h>
#include <assert.h> #include <assert.h>
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#include <unistd.h> #include <unistd.h>
#include <poll.h> #include <poll.h>
#include <vlc_charset.h> #include <vlc_fs.h>
#include "libmtp.h" #include "libmtp.h"
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_access.h> #include <vlc_access.h>
#include <vlc_demux.h> #include <vlc_demux.h>
#include <vlc_charset.h> #include <vlc_fs.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_access.h> #include <vlc_access.h>
#include <vlc_charset.h> #include <vlc_fs.h>
#include <sys/types.h> #include <sys/types.h>
#include <fcntl.h> #include <fcntl.h>
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#endif #endif
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_charset.h> #include <vlc_fs.h>
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_access.h> #include <vlc_access.h>
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include <vlc_demux.h> #include <vlc_demux.h>
#include <vlc_access.h> #include <vlc_access.h>
#include <vlc_picture.h> #include <vlc_picture.h>
#include <vlc_charset.h> #include <vlc_fs.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/mman.h> #include <sys/mman.h>
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_access.h> #include <vlc_access.h>
#include <vlc_charset.h> #include <vlc_charset.h>
#include <vlc_fs.h>
#include <vlc_demux.h> #include <vlc_demux.h>
#include <vlc_input.h> #include <vlc_input.h>
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_access.h> #include <vlc_access.h>
#include <vlc_charset.h> #include <vlc_charset.h>
#include <vlc_fs.h>
#include <limits.h> #include <limits.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
...@@ -77,7 +78,6 @@ ...@@ -77,7 +78,6 @@
#include "cdrom_internals.h" #include "cdrom_internals.h"
#include "cdrom.h" #include "cdrom.h"
#include <vlc_charset.h>
#include <vlc_meta.h> #include <vlc_meta.h>
/***************************************************************************** /*****************************************************************************
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_charset.h>
#include "vcd.h" #include "vcd.h"
#include "access.h" #include "access.h"
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_sout.h> #include <vlc_sout.h>
#include <vlc_block.h> #include <vlc_block.h>
#include <vlc_charset.h> #include <vlc_fs.h>
#include <vlc_strings.h> #include <vlc_strings.h>
#if defined( WIN32 ) && !defined( UNDER_CE ) #if defined( WIN32 ) && !defined( UNDER_CE )
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_aout.h> #include <vlc_aout.h>
#include <vlc_codecs.h> /* WAVEHEADER */ #include <vlc_codecs.h> /* WAVEHEADER */
#include <vlc_charset.h> #include <vlc_fs.h>
#define FRAME_SIZE 2048 #define FRAME_SIZE 2048
#define A52_FRAME_NB 1536 #define A52_FRAME_NB 1536
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_charset.h> #include <vlc_fs.h>
#include <vlc_aout.h> #include <vlc_aout.h>
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include <vlc_image.h> #include <vlc_image.h>
#include <vlc_filter.h> #include <vlc_filter.h>
#include <vlc_charset.h>
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "http.h" #include "http.h"
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_url.h> #include <vlc_url.h>
#include <vlc_fs.h>
#include <assert.h> #include <assert.h>
......
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include <vlc_vlm.h> #include <vlc_vlm.h>
#include <vlc_network.h> #include <vlc_network.h>
#include <vlc_acl.h> #include <vlc_acl.h>
#include <vlc_charset.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
# include <unistd.h> # include <unistd.h>
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#ifdef HAVE_SYS_STAT_H #ifdef HAVE_SYS_STAT_H
#include <sys/stat.h> #include <sys/stat.h>
#endif #endif
#include <vlc_fs.h>
/* Utility function for scandir */ /* Utility function for scandir */
static int Filter( const char *foo ) static int Filter( const char *foo )
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <vlc_fs.h>
/**************************************************************************** /****************************************************************************
* File and directory functions * File and directory functions
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_demux.h> #include <vlc_demux.h>
#include <vlc_charset.h> #include <vlc_fs.h>
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_md5.h> #include <vlc_md5.h>
#include "libmp4.h" #include "libmp4.h"
#include <vlc_charset.h> #include <vlc_fs.h>
#ifdef WIN32 #ifdef WIN32
# include <io.h> # include <io.h>
......
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
#include <vlc_codecs.h> #include <vlc_codecs.h>
#include <vlc_bits.h> #include <vlc_bits.h>
#include <vlc_charset.h>
#include "vorbis.h" #include "vorbis.h"
#include "kate_categories.h" #include "kate_categories.h"
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_demux.h> #include <vlc_demux.h>
#include <vlc_charset.h>
#include "playlist.h" #include "playlist.h"
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_demux.h> #include <vlc_demux.h>
#include <vlc_charset.h>
#include "playlist.h" #include "playlist.h"
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include <vlc_memory.h> #include <vlc_memory.h>
#include <vlc_demux.h> #include <vlc_demux.h>
#include <vlc_charset.h>
#include "asademux.h" #include "asademux.h"
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <vlc_iso_lang.h> #include <vlc_iso_lang.h>
#include <vlc_network.h> #include <vlc_network.h>
#include <vlc_charset.h> #include <vlc_charset.h>
#include <vlc_fs.h>
#include "../mux/mpeg/csa.h" #include "../mux/mpeg/csa.h"
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include <limits.h> #include <limits.h>
#include <vlc_demux.h> #include <vlc_demux.h>
#include <vlc_charset.h>
#include "ps.h" #include "ps.h"
#include "vobsub.h" #include "vobsub.h"
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#include <vlc_charset.h>
static inline void vorbis_ParseComment( vlc_meta_t **pp_meta, const uint8_t *p_data, int i_data ) static inline void vorbis_ParseComment( vlc_meta_t **pp_meta, const uint8_t *p_data, int i_data )
{ {
int n; int n;
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <vlc_common.h>