+
+/*****************************************************************************
+ * OpenFile: Opens a specific file
+ *****************************************************************************/
+static int _OpenFile( access_t * p_access, const char * psz_name )
+{
+ access_sys_t *p_sys = p_access->p_sys;
+
+#ifdef UNDER_CE
+ p_sys->fd = utf8_fopen( psz_name, "rb" );
+ if ( !p_sys->fd )
+ {
+ msg_Err( p_access, "cannot open file %s", psz_name );
+ return VLC_EGENERIC;
+ }
+
+ fseek( p_sys->fd, 0, SEEK_END );
+ p_access->info.i_size = ftell( p_sys->fd );
+ p_access->info.i_update |= INPUT_UPDATE_SIZE;
+ fseek( p_sys->fd, 0, SEEK_SET );
+#else
+ const char *psz_localname = ToLocale( psz_name );
+ if( psz_localname == NULL )
+ {
+ msg_Err( p_access, "incorrect file name %s", psz_name );
+ return VLC_EGENERIC;
+ }
+
+ // FIXME: support non-ANSI filenames on Win32
+ p_sys->fd = open( psz_localname, O_NONBLOCK /*| O_LARGEFILE*/ );
+ LocaleFree( psz_localname );
+
+ if ( p_sys->fd == -1 )
+ {
+ msg_Err( p_access, "cannot open file %s (%s)", psz_name,
+ strerror(errno) );
+ return VLC_EGENERIC;
+ }
+
+#if defined(HAVE_FCNTL_H) && defined(F_FDAHEAD) && defined(F_NOCACHE)
+ /* We'd rather use any available memory for reading ahead
+ * than for caching what we've already seen/heard */
+ fcntl(p_sys->fd, F_RDAHEAD, 1);
+ fcntl(p_sys->fd, F_NOCACHE, 1);
+#endif
+
+#endif
+
+ return VLC_SUCCESS;
+}