* file.c: file input (file: access plug-in)
*****************************************************************************
* Copyright (C) 2001-2006 the VideoLAN team
- * Copyright © 2006 Rémi Denis-Courmont
+ * Copyright © 2006-2007 Rémi Denis-Courmont
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
/*****************************************************************************
* Preamble
*****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <vlc/vlc.h>
#include <vlc_input.h>
#include <vlc_access.h>
#include <vlc_interface.h>
+#include <assert.h>
#include <errno.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#define CACHING_LONGTEXT N_( \
"Caching value for files. This " \
"value should be set in milliseconds." )
-#define CAT_TEXT N_("Concatenate with additional files")
-#define CAT_LONGTEXT N_( \
- "Play split files as if they were part of a unique file. " \
- "You need to specify a comma-separated list of files." )
vlc_module_begin();
set_description( _("File input") );
* Exported prototypes
*****************************************************************************/
static int Seek( access_t *, int64_t );
-static int Read( access_t *, uint8_t *, int );
+static ssize_t Read( access_t *, uint8_t *, size_t );
static int Control( access_t *, int, va_list );
static int open_file( access_t *, const char * );
while (fd != -1)
{
if (fstat (fd, &st))
- msg_Err (p_access, "fstat(%d): %s", fd, strerror (errno));
+ msg_Err (p_access, "fstat(%d): %m", fd);
else
if (S_ISDIR (st.st_mode))
/* The directory plugin takes care of that */
#ifdef HAVE_SYS_STAT_H
p_access->info.i_size = st.st_size;
- if (!S_ISREG (st.st_mode) && !S_ISBLK (st.st_mode)
- && (!S_ISCHR (st.st_mode) || (st.st_size == 0)))
+ if (!S_ISREG (st.st_mode)
+ && !S_ISBLK (st.st_mode)
+ && !S_ISCHR (st.st_mode))
p_sys->b_seekable = VLC_FALSE;
#else
p_sys->b_seekable = !b_stdin;
# warning File size not known!
#endif
- if (p_sys->b_seekable && (p_access->info.i_size == 0))
- {
- /* FIXME that's bad because all others access will be probed */
- msg_Err (p_access, "file is empty, aborting");
- Close (p_this);
- return VLC_EGENERIC;
- }
-
return VLC_SUCCESS;
}
/*****************************************************************************
* Read: standard read on a file descriptor.
*****************************************************************************/
-static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
+static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
{
access_sys_t *p_sys = p_access->p_sys;
- int i_ret;
+ ssize_t i_ret;
int fd = p_sys->fd;
#if !defined(WIN32) && !defined(UNDER_CE)
break;
default:
- msg_Err (p_access, "read failed (%s)", strerror (errno));
+ msg_Err (p_access, "read failed (%m)");
intf_UserFatal (p_access, VLC_FALSE, _("File reading failed"),
- _("VLC could not read file \"%s\"."),
- strerror (errno));
+ _("VLC could not read the file."));
}
/* Delay a bit to avoid consuming all the CPU. This is particularly
return i_ret;
}
+
/*****************************************************************************
* Seek: seek to a specific location in a file
*****************************************************************************/
static int Seek (access_t *p_access, int64_t i_pos)
{
- if (i_pos > p_access->info.i_size)
- {
- msg_Err (p_access, "seeking too far");
- i_pos = p_access->info.i_size;
- }
- else if (i_pos < 0)
- {
- msg_Err (p_access, "seeking too early");
- i_pos = 0;
- }
-
p_access->info.i_pos = i_pos;
p_access->info.b_eof = VLC_FALSE;
- /* Determine which file we need to access */
lseek (p_access->p_sys->fd, i_pos, SEEK_SET);
return VLC_SUCCESS;
}
case ACCESS_SET_SEEKPOINT:
case ACCESS_SET_PRIVATE_ID_STATE:
case ACCESS_GET_META:
+ case ACCESS_GET_PRIVATE_ID_STATE:
+ case ACCESS_GET_CONTENT_TYPE:
return VLC_EGENERIC;
default:
- msg_Warn( p_access, "unimplemented query in control" );
+ msg_Warn( p_access, "unimplemented query %d in control", i_query );
return VLC_EGENERIC;
}
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 );
+ intf_UserFatal( p_access, VLC_FALSE, _("File reading failed"),
+ _("VLC could not open the file \"%s\"."), psz_name );
free (path);
return VLC_EGENERIC;
}
free (path);
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));
+ msg_Err (p_access, "cannot open file %s (%m)", psz_name);
+ intf_UserFatal (p_access, VLC_FALSE, _("File reading failed"),
+ _("VLC could not open the file \"%s\"."), psz_name);
return -1;
}