Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
c0660ee3
Commit
c0660ee3
authored
Nov 01, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
file: restore file descriptor support (fixes #14897)
parent
024cbe94
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
101 deletions
+42
-101
modules/access/directory.c
modules/access/directory.c
+27
-87
modules/access/file.c
modules/access/file.c
+15
-14
No files found.
modules/access/directory.c
View file @
c0660ee3
...
...
@@ -36,16 +36,8 @@
#include <vlc_access.h>
#include <vlc_input_item.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <vlc_fs.h>
#include <vlc_url.h>
#include <vlc_strings.h>
#include <vlc_charset.h>
struct
access_sys_t
{
...
...
@@ -60,14 +52,6 @@ int DirInit (access_t *p_access, DIR *p_dir)
{
char
*
psz_base_uri
;
if
(
!
p_access
->
psz_filepath
)
return
VLC_EGENERIC
;
if
(
!
p_dir
)
p_dir
=
vlc_opendir
(
p_access
->
psz_filepath
);
if
(
p_dir
==
NULL
)
return
VLC_EGENERIC
;
if
(
!
strcmp
(
p_access
->
psz_access
,
"fd"
))
{
if
(
asprintf
(
&
psz_base_uri
,
"fd://%s"
,
p_access
->
psz_location
)
==
-
1
)
...
...
@@ -81,7 +65,6 @@ int DirInit (access_t *p_access, DIR *p_dir)
return
VLC_ENOMEM
;
}
p_access
->
p_sys
=
calloc
(
1
,
sizeof
(
access_sys_t
));
if
(
!
p_access
->
p_sys
)
{
...
...
@@ -102,7 +85,16 @@ int DirInit (access_t *p_access, DIR *p_dir)
*****************************************************************************/
int
DirOpen
(
vlc_object_t
*
p_this
)
{
return
DirInit
((
access_t
*
)
p_this
,
NULL
);
access_t
*
access
=
(
access_t
*
)
p_this
;
if
(
access
->
psz_filepath
==
NULL
)
return
VLC_EGENERIC
;
DIR
*
dir
=
vlc_opendir
(
access
->
psz_filepath
);
if
(
dir
==
NULL
)
return
VLC_EGENERIC
;
return
DirInit
(
access
,
dir
);
}
/*****************************************************************************
...
...
@@ -119,83 +111,31 @@ void DirClose( vlc_object_t * p_this )
free
(
p_sys
);
}
static
bool
is_looping
(
access_t
*
p_access
,
const
char
*
psz_uri
)
{
#ifdef S_ISLNK
struct
stat
st
;
bool
b_looping
=
false
;
if
(
vlc_lstat
(
psz_uri
,
&
st
)
!=
0
)
return
false
;
if
(
S_ISLNK
(
st
.
st_mode
))
{
char
*
psz_link
=
malloc
(
st
.
st_size
+
1
);
ssize_t
i_ret
;
if
(
psz_link
)
{
i_ret
=
readlink
(
psz_uri
,
psz_link
,
st
.
st_size
+
1
);
if
(
i_ret
>
0
&&
i_ret
<=
st
.
st_size
)
{
psz_link
[
i_ret
]
=
'\0'
;
if
(
strstr
(
p_access
->
psz_filepath
,
psz_link
))
b_looping
=
true
;
}
free
(
psz_link
);
}
}
return
b_looping
;
#else
VLC_UNUSED
(
p_access
);
VLC_UNUSED
(
psz_uri
);
return
false
;
#endif
}
input_item_t
*
DirRead
(
access_t
*
p_access
)
{
access_sys_t
*
p_sys
=
p_access
->
p_sys
;
DIR
*
p_dir
=
p_sys
->
p_dir
;
input_item_t
*
p_item
=
NULL
;
const
char
*
psz_entry
;
while
(
!
p_item
&&
(
psz_entry
=
vlc_readdir
(
p_dir
)))
{
char
*
psz_uri
,
*
psz_encoded_entry
;
struct
stat
st
;
int
i_type
;
const
char
*
entry
;
/* Check if it is a directory or even readable */
if
(
asprintf
(
&
psz_uri
,
"%s/%s"
,
p_access
->
psz_filepath
,
psz_entry
)
==
-
1
)
return
NULL
;
if
(
vlc_stat
(
psz_uri
,
&
st
)
!=
0
)
{
free
(
psz_uri
);
continue
;
}
i_type
=
S_ISDIR
(
st
.
st_mode
)
?
ITEM_TYPE_DIRECTORY
:
ITEM_TYPE_FILE
;
if
(
i_type
==
ITEM_TYPE_DIRECTORY
&&
is_looping
(
p_access
,
psz_uri
))
while
((
entry
=
vlc_readdir
(
p_sys
->
p_dir
))
!=
NULL
)
{
free
(
psz_uri
);
continue
;
}
free
(
psz_uri
);
/* Create an input item for the current entry */
psz_encoded_entry
=
encode_URI_component
(
psz_entry
);
if
(
psz_encoded_entry
==
NULL
)
continue
;
if
(
asprintf
(
&
psz_uri
,
"%s/%s"
,
p_sys
->
psz_base_uri
,
psz_encoded_entry
)
==
-
1
)
char
*
encoded_entry
=
encode_URI_component
(
entry
);
if
(
unlikely
(
entry
==
NULL
))
return
NULL
;
free
(
psz_encoded_entry
);
p_item
=
input_item_NewWithType
(
psz_uri
,
psz_entry
,
0
,
NULL
,
0
,
0
,
i_type
);
free
(
psz_uri
);
if
(
!
p_item
)
char
*
uri
;
if
(
unlikely
(
asprintf
(
&
uri
,
"%s/%s"
,
p_sys
->
psz_base_uri
,
encoded_entry
)
==
-
1
))
uri
=
NULL
;
free
(
encoded_entry
);
if
(
unlikely
(
uri
==
NULL
))
return
NULL
;
input_item_t
*
item
=
input_item_NewWithType
(
uri
,
entry
,
0
,
NULL
,
0
,
0
,
ITEM_TYPE_FILE
);
free
(
uri
);
if
(
likely
(
item
!=
NULL
))
return
item
;
}
return
p_item
;
return
NULL
;
}
modules/access/file.c
View file @
c0660ee3
...
...
@@ -163,23 +163,24 @@ int FileOpen( vlc_object_t *p_this )
}
else
{
const
char
*
path
=
p_access
->
psz_filepath
;
if
(
unlikely
(
path
==
NULL
))
if
(
unlikely
(
p_access
->
psz_filepath
==
NULL
))
return
VLC_EGENERIC
;
msg_Dbg
(
p_access
,
"opening file `%s'"
,
path
);
fd
=
vlc_open
(
path
,
O_RDONLY
|
O_NONBLOCK
);
fd
=
vlc_open
(
p_access
->
psz_filepath
,
O_RDONLY
|
O_NONBLOCK
);
}
if
(
fd
==
-
1
)
{
msg_Err
(
p_access
,
"cannot open file %s (%s)"
,
path
,
msg_Err
(
p_access
,
"cannot open file %s (%s)"
,
p_access
->
psz_filepath
?
p_access
->
psz_filepath
:
p_access
->
psz_location
,
vlc_strerror_c
(
errno
));
dialog_Fatal
(
p_access
,
_
(
"File reading failed"
),
_
(
"VLC could not open the file
\"
%s
\"
(%s)."
),
path
,
_
(
"VLC could not open the file
\"
%s
\"
(%s)."
),
p_access
->
psz_filepath
?
p_access
->
psz_filepath
:
p_access
->
psz_location
,
vlc_strerror
(
errno
));
}
}
if
(
fd
==
-
1
)
return
VLC_EGENERIC
;
}
struct
stat
st
;
if
(
fstat
(
fd
,
&
st
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment