Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
ef0392e8
Commit
ef0392e8
authored
Oct 04, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input/file: use errno_quark()
parent
efbf184f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
11 deletions
+6
-11
file_input_plugin.c
src/input/file_input_plugin.c
+6
-11
No files found.
src/input/file_input_plugin.c
View file @
ef0392e8
...
...
@@ -23,6 +23,7 @@
#include "input_plugin.h"
#include "fd_util.h"
#include "open.h"
#include "io_error.h"
#include <sys/stat.h>
#include <unistd.h>
...
...
@@ -39,12 +40,6 @@ struct file_input_stream {
int
fd
;
};
static
inline
GQuark
file_quark
(
void
)
{
return
g_quark_from_static_string
(
"file"
);
}
static
struct
input_stream
*
input_file_open
(
const
char
*
filename
,
GMutex
*
mutex
,
GCond
*
cond
,
...
...
@@ -60,7 +55,7 @@ input_file_open(const char *filename,
fd
=
open_cloexec
(
filename
,
O_RDONLY
|
O_BINARY
,
0
);
if
(
fd
<
0
)
{
if
(
errno
!=
ENOENT
&&
errno
!=
ENOTDIR
)
g_set_error
(
error_r
,
file
_quark
(),
errno
,
g_set_error
(
error_r
,
errno
_quark
(),
errno
,
"Failed to open
\"
%s
\"
: %s"
,
filename
,
g_strerror
(
errno
));
return
NULL
;
...
...
@@ -68,7 +63,7 @@ input_file_open(const char *filename,
ret
=
fstat
(
fd
,
&
st
);
if
(
ret
<
0
)
{
g_set_error
(
error_r
,
file
_quark
(),
errno
,
g_set_error
(
error_r
,
errno
_quark
(),
errno
,
"Failed to stat
\"
%s
\"
: %s"
,
filename
,
g_strerror
(
errno
));
close
(
fd
);
...
...
@@ -76,7 +71,7 @@ input_file_open(const char *filename,
}
if
(
!
S_ISREG
(
st
.
st_mode
))
{
g_set_error
(
error_r
,
file
_quark
(),
0
,
g_set_error
(
error_r
,
errno
_quark
(),
0
,
"Not a regular file: %s"
,
filename
);
close
(
fd
);
return
NULL
;
...
...
@@ -107,7 +102,7 @@ input_file_seek(struct input_stream *is, goffset offset, int whence,
offset
=
(
goffset
)
lseek
(
fis
->
fd
,
(
off_t
)
offset
,
whence
);
if
(
offset
<
0
)
{
g_set_error
(
error_r
,
file
_quark
(),
errno
,
g_set_error
(
error_r
,
errno
_quark
(),
errno
,
"Failed to seek: %s"
,
g_strerror
(
errno
));
return
false
;
}
...
...
@@ -125,7 +120,7 @@ input_file_read(struct input_stream *is, void *ptr, size_t size,
nbytes
=
read
(
fis
->
fd
,
ptr
,
size
);
if
(
nbytes
<
0
)
{
g_set_error
(
error_r
,
file
_quark
(),
errno
,
g_set_error
(
error_r
,
errno
_quark
(),
errno
,
"Failed to read: %s"
,
g_strerror
(
errno
));
return
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