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

Get rid of broken file-cat option (closes #807)

parent 6b623212
...@@ -92,7 +92,7 @@ vlc_module_begin(); ...@@ -92,7 +92,7 @@ vlc_module_begin();
set_category( CAT_INPUT ); set_category( CAT_INPUT );
set_subcategory( SUBCAT_INPUT_ACCESS ); set_subcategory( SUBCAT_INPUT_ACCESS );
add_integer( "file-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE ); add_integer( "file-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
add_string( "file-cat", NULL, NULL, CAT_TEXT, CAT_LONGTEXT, VLC_TRUE ); add_deprecated( "file-cat", VLC_TRUE );
set_capability( "access2", 50 ); set_capability( "access2", 50 );
add_shortcut( "file" ); add_shortcut( "file" );
add_shortcut( "stream" ); add_shortcut( "stream" );
...@@ -115,13 +115,7 @@ struct access_sys_t ...@@ -115,13 +115,7 @@ struct access_sys_t
unsigned int i_nb_reads; unsigned int i_nb_reads;
vlc_bool_t b_kfir; vlc_bool_t b_kfir;
/* Files list */ int fd;
unsigned filec;
int *filev;
int64_t *sizev;
/* Current file */
unsigned filep;
/* */ /* */
vlc_bool_t b_seekable; vlc_bool_t b_seekable;
...@@ -135,7 +129,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -135,7 +129,6 @@ static int Open( vlc_object_t *p_this )
{ {
access_t *p_access = (access_t*)p_this; access_t *p_access = (access_t*)p_this;
access_sys_t *p_sys; access_sys_t *p_sys;
char *catlist;
vlc_bool_t b_stdin = !strcmp (p_access->psz_path, "-"); vlc_bool_t b_stdin = !strcmp (p_access->psz_path, "-");
...@@ -145,8 +138,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -145,8 +138,7 @@ static int Open( vlc_object_t *p_this )
STANDARD_READ_ACCESS_INIT; STANDARD_READ_ACCESS_INIT;
p_sys->i_nb_reads = 0; p_sys->i_nb_reads = 0;
p_sys->b_kfir = VLC_FALSE; p_sys->b_kfir = VLC_FALSE;
p_sys->filec = 1; int fd = p_sys->fd = -1;
p_sys->filep = 0;
if (!strcasecmp (p_access->psz_access, "stream")) if (!strcasecmp (p_access->psz_access, "stream"))
{ {
...@@ -165,114 +157,50 @@ static int Open( vlc_object_t *p_this ) ...@@ -165,114 +157,50 @@ static int Open( vlc_object_t *p_this )
p_sys->b_pace_control = VLC_TRUE; p_sys->b_pace_control = VLC_TRUE;
} }
/* Count number of files */ /* Open file */
catlist = var_CreateGetString (p_access, "file-cat"); msg_Dbg (p_access, "opening file `%s'", p_access->psz_path);
if (catlist == NULL)
{
free (p_sys);
return VLC_ENOMEM;
}
if (*catlist)
{
for (const char *ptr = catlist; ptr != NULL; p_sys->filec++)
{
ptr = strchr (ptr, ',');
if (ptr != NULL)
ptr++;
}
}
p_sys->filev = calloc (p_sys->filec, sizeof (p_sys->filev[0])); if (b_stdin)
if (p_sys->filev == NULL) fd = dup (0);
{ else
free (catlist); fd = open_file (p_access, p_access->psz_path);
free (p_sys);
return VLC_ENOMEM;
}
p_sys->sizev = calloc (p_sys->filec, sizeof (p_sys->sizev[0])); #ifdef HAVE_SYS_STAT_H
if (p_sys->sizev == NULL) struct stat st;
{
free (catlist);
free (p_sys->filev);
free (p_sys);
return VLC_ENOMEM;
}
/* Open files */ while (fd != -1)
char *filename = catlist;
for (unsigned i = 0; i < p_sys->filec; i++)
{ {
int fd = -1; if (fstat (fd, &st))
msg_Err (p_access, "fstat(%d): %s", fd, strerror (errno));
if (i == 0)
{
msg_Dbg (p_access, "opening file `%s'", p_access->psz_path);
if (b_stdin)
fd = dup (0);
else
fd = open_file (p_access, p_access->psz_path);
}
else else
{ if (S_ISDIR (st.st_mode))
assert (filename != NULL); /* The directory plugin takes care of that */
msg_Dbg (p_access, "file is a directory, aborting");
char *ptr = strchr (filename, ','); else
if (ptr != NULL) break; // success
*ptr = 0;
msg_Dbg (p_access, "opening additionnal file `%s'", filename);
fd = open_file (p_access, filename);
filename = ptr + 1;
}
#ifdef HAVE_SYS_STAT_H
struct stat st;
while (fd != -1) close (fd);
{ fd = -1;
if (fstat (fd, &st)) }
msg_Err (p_access, "fstat(%d): %s", fd, strerror (errno));
else
if (S_ISDIR (st.st_mode))
/* The directory plugin takes care of that */
msg_Dbg (p_access, "file is a directory, aborting");
else
break; // success
close (fd);
fd = -1;
}
#endif #endif
if (fd == -1) if (fd == -1)
{ {
free (catlist); free (p_sys);
p_sys->filec = i; return VLC_EGENERIC;
Close (p_this); }
return VLC_EGENERIC; p_sys->fd = fd;
}
p_sys->filev[i] = fd;
#ifdef HAVE_SYS_STAT_H #ifdef HAVE_SYS_STAT_H
p_sys->sizev[i] = st.st_size; p_access->info.i_size = st.st_size;
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) p_sys->b_seekable = VLC_FALSE;
&& (!S_ISCHR (st.st_mode) || (st.st_size == 0)))
// If one file is not seekable, the concatenation is not either
p_sys->b_seekable = VLC_FALSE;
#else #else
p_sys->b_seekable = !b_stdin; p_sys->b_seekable = !b_stdin;
#endif #endif
} if (p_sys->b_seekable && (p_access->info.i_size == 0))
free (catlist);
if (p_sys->b_seekable && !p_access->info.i_size)
{ {
/* FIXME that's bad because all others access will be probed */ /* FIXME that's bad because all others access will be probed */
msg_Err (p_access, "file is empty, aborting"); msg_Err (p_access, "file is empty, aborting");
...@@ -291,11 +219,7 @@ static void Close (vlc_object_t * p_this) ...@@ -291,11 +219,7 @@ static void Close (vlc_object_t * p_this)
access_t *p_access = (access_t*)p_this; access_t *p_access = (access_t*)p_this;
access_sys_t *p_sys = p_access->p_sys; access_sys_t *p_sys = p_access->p_sys;
for (unsigned i = 0; i < p_sys->filec; i++) close (p_sys->fd);
close (p_sys->filev[i]);
free (p_sys->filev);
free (p_sys->sizev);
free (p_sys); free (p_sys);
} }
...@@ -306,7 +230,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len ) ...@@ -306,7 +230,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
{ {
access_sys_t *p_sys = p_access->p_sys; access_sys_t *p_sys = p_access->p_sys;
int i_ret; int i_ret;
int fd = p_sys->filev[p_sys->filep]; int fd = p_sys->fd;
#if !defined(WIN32) && !defined(UNDER_CE) #if !defined(WIN32) && !defined(UNDER_CE)
if( !p_sys->b_pace_control ) if( !p_sys->b_pace_control )
...@@ -373,28 +297,16 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len ) ...@@ -373,28 +297,16 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
(p_sys->i_nb_reads % INPUT_FSTAT_NB_READS) == 0 ) (p_sys->i_nb_reads % INPUT_FSTAT_NB_READS) == 0 )
{ {
struct stat st; struct stat st;
int i = p_sys->filep;
if ((fstat (fd, &st) == 0) if ((fstat (fd, &st) == 0)
&& (p_sys->sizev[i] != st.st_size)) && (p_access->info.i_size != st.st_size))
{ {
p_access->info.i_size += st.st_size - p_sys->sizev[i]; p_access->info.i_size = st.st_size;
p_sys->sizev[i] = st.st_size;
p_access->info.i_update |= INPUT_UPDATE_SIZE; p_access->info.i_update |= INPUT_UPDATE_SIZE;
} }
} }
#endif #endif
/* If we reached an EOF then switch to the next file in the list */
if (i_ret == 0)
{
if (++p_sys->filep < p_sys->filec)
/* We have to read some data */
return Read (p_access, p_buffer, i_len);
else
p_sys->filep--;
}
if( i_ret > 0 ) if( i_ret > 0 )
p_access->info.i_pos += i_ret; p_access->info.i_pos += i_ret;
else if( i_ret == 0 ) else if( i_ret == 0 )
...@@ -425,17 +337,7 @@ static int Seek (access_t *p_access, int64_t i_pos) ...@@ -425,17 +337,7 @@ static int Seek (access_t *p_access, int64_t i_pos)
p_access->info.b_eof = VLC_FALSE; p_access->info.b_eof = VLC_FALSE;
/* Determine which file we need to access */ /* Determine which file we need to access */
unsigned i = 0; lseek (p_sys->fd, i_pos, SEEK_SET);
assert (p_sys->filec > 0);
while (i_pos > p_sys->sizev[i])
{
i_pos -= p_sys->sizev[i++];
assert (i < p_sys->filec);
}
p_sys->filep = i;
lseek (p_sys->filev[i], i_pos, SEEK_SET);
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment