-
-
-static char *expand_path (const access_t *p_access, const char *path)
-{
- if (strncmp (path, "~/", 2) == 0)
- {
- char *res;
-
- // TODO: we should also support the ~cmassiot/ syntax
- if (asprintf (&res, "%s/%s", p_access->p_libvlc->psz_homedir, path + 2) == -1)
- return NULL;
- return res;
- }
-
-#if defined(WIN32)
- if (!strcasecmp (p_access->psz_access, "file")
- && ('/' == path[0]) && path[1] && (':' == path[2]) && ('/' == path[3]))
- // Explorer can open path such as file:/C:/ or file:///C:/
- // hence remove leading / if found
- return strdup (path + 1);
-#endif
-
- return strdup (path);
-}
-
-
-/*****************************************************************************
- * open_file: Opens a specific file
- *****************************************************************************/
-static int open_file (access_t *p_access, const char *psz_name)
-{
- char *path = expand_path (p_access, psz_name);
-
-#ifdef UNDER_CE
- p_sys->fd = utf8_fopen( path, "rb" );
- if ( !p_sys->fd )
- {
- msg_Err( p_access, "cannot open file %s", psz_name );
- intf_UserFatal( p_access, VLC_FALSE, _("File reading failed"),
- _("VLC could not open file \"%s\"."), psz_name );
- free (path);
- 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
- int fd = utf8_open (path, O_RDONLY | O_NONBLOCK /* O_LARGEFILE*/, 0666);
- if (fd == -1)
- {
- msg_Err (p_access, "cannot open file %s (%s)", psz_name,
- strerror (errno));
- intf_UserFatal (p_access, VLC_FALSE, _("File reading failed"),
- _("VLC could not open file \"%s\" (%s)."),
- psz_name, strerror (errno));
- return -1;
- }
-
-# 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 (fd, F_RDAHEAD, 1);
- fcntl (fd, F_NOCACHE, 1);
-# endif
-#endif
-
- return fd;
-}