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
9d669888
Commit
9d669888
authored
Jun 30, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
file: use vlc_read_i11e() and simplify
parent
d71bd09f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
38 deletions
+13
-38
modules/access/file.c
modules/access/file.c
+13
-38
No files found.
modules/access/file.c
View file @
9d669888
...
...
@@ -63,6 +63,7 @@
#endif
#include <vlc_fs.h>
#include <vlc_url.h>
#include <vlc_interrupt.h>
struct
access_sys_t
{
...
...
@@ -190,14 +191,8 @@ int FileOpen( vlc_object_t *p_this )
}
#if O_NONBLOCK
int
flags
=
fcntl
(
fd
,
F_GETFL
);
if
(
S_ISFIFO
(
st
.
st_mode
)
||
S_ISSOCK
(
st
.
st_mode
))
/* Force non-blocking mode where applicable (fd://) */
flags
|=
O_NONBLOCK
;
else
/* Force blocking mode when not useful or not specified */
flags
&=
~
O_NONBLOCK
;
fcntl
(
fd
,
F_SETFL
,
flags
);
/* Force blocking mode back */
fcntl
(
fd
,
fcntl
(
fd
,
F_GETFL
)
&
~
O_NONBLOCK
);
#endif
/* Directories can be opened and read from, but only readdir() knows
...
...
@@ -282,42 +277,23 @@ void FileClose (vlc_object_t * p_this)
}
#include <vlc_network.h>
/**
* Reads from a regular file.
*/
static
ssize_t
FileRead
(
access_t
*
p_access
,
uint8_t
*
p_buffer
,
size_t
i_len
)
{
access_sys_t
*
p_sys
=
p_access
->
p_sys
;
int
fd
=
p_sys
->
fd
;
ssize_t
val
=
read
(
fd
,
p_buffer
,
i_len
);
if
(
val
<
0
)
{
switch
(
errno
)
{
case
EINTR
:
case
EAGAIN
:
return
-
1
;
}
ssize_t
val
=
StreamRead
(
p_access
,
p_buffer
,
i_len
);
msg_Err
(
p_access
,
"read error: %s"
,
vlc_strerror_c
(
errno
));
dialog_Fatal
(
p_access
,
_
(
"File reading failed"
),
_
(
"VLC could not read the file (%s)."
),
vlc_strerror
(
errno
));
val
=
0
;
}
access_sys_t
*
p_sys
=
p_access
->
p_sys
;
p_access
->
info
.
i_pos
+=
val
;
p_access
->
info
.
b_eof
=
!
val
;
if
(
p_access
->
info
.
i_pos
>=
p_sys
->
size
)
{
struct
stat
st
;
if
(
fstat
(
fd
,
&
st
)
==
0
)
p_sys
->
size
=
st
.
st_size
;
if
(
fstat
(
p_sys
->
fd
,
&
st
)
==
0
)
p_sys
->
size
=
st
.
st_size
;
}
return
val
;
}
...
...
@@ -343,12 +319,7 @@ static ssize_t StreamRead (access_t *p_access, uint8_t *p_buffer, size_t i_len)
access_sys_t
*
p_sys
=
p_access
->
p_sys
;
int
fd
=
p_sys
->
fd
;
#if !defined (_WIN32) && !defined (__OS2__)
ssize_t
val
=
net_Read
(
p_access
,
fd
,
p_buffer
,
i_len
,
false
);
#else
ssize_t
val
=
read
(
fd
,
p_buffer
,
i_len
);
#endif
ssize_t
val
=
vlc_read_i11e
(
fd
,
p_buffer
,
i_len
);
if
(
val
<
0
)
{
switch
(
errno
)
...
...
@@ -357,7 +328,11 @@ static ssize_t StreamRead (access_t *p_access, uint8_t *p_buffer, size_t i_len)
case
EAGAIN
:
return
-
1
;
}
msg_Err
(
p_access
,
"read error: %s"
,
vlc_strerror_c
(
errno
));
dialog_Fatal
(
p_access
,
_
(
"File reading failed"
),
_
(
"VLC could not read the file (%s)."
),
vlc_strerror
(
errno
));
val
=
0
;
}
...
...
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