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
c727e869
Commit
c727e869
authored
May 20, 2010
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input/file, output/{fifo,recorder}: add O_BINARY to open() flags
Windows compatibility.
parent
57b40133
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
7 deletions
+49
-7
file_input_plugin.c
src/input/file_input_plugin.c
+2
-2
open.h
src/open.h
+41
-0
fifo_output_plugin.c
src/output/fifo_output_plugin.c
+3
-3
recorder_output_plugin.c
src/output/recorder_output_plugin.c
+3
-2
No files found.
src/input/file_input_plugin.c
View file @
c727e869
...
...
@@ -21,9 +21,9 @@
#include "input/file_input_plugin.h"
#include "input_plugin.h"
#include "fd_util.h"
#include "open.h"
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
...
...
@@ -54,7 +54,7 @@ input_file_open(const char *filename, GError **error_r)
if
(
!
g_path_is_absolute
(
filename
))
return
false
;
fd
=
open_cloexec
(
filename
,
O_RDONLY
,
0
);
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
,
...
...
src/open.h
0 → 100644
View file @
c727e869
/*
* Copyright (C) 2003-2010 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/** \file
*
* Portability macros for opening files.
*/
#ifndef MPD_OPEN_H
#define MPD_OPEN_H
#include <fcntl.h>
/* On Windows, files are opened in "text" mode by default, and the C
library will mangle data being read/written; this must be switched
off by specifying the proprietary "O_BINARY" flag. That sucks! */
#ifndef O_BINARY
#ifdef _O_BINARY
#define O_BINARY _O_BINARY
#else
#define O_BINARY 0
#endif
#endif
#endif
src/output/fifo_output_plugin.c
View file @
c727e869
...
...
@@ -22,12 +22,12 @@
#include "utils.h"
#include "timer.h"
#include "fd_util.h"
#include "open.h"
#include <glib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
...
...
@@ -154,7 +154,7 @@ fifo_open(struct fifo_data *fd, GError **error)
if
(
!
fifo_check
(
fd
,
error
))
return
false
;
fd
->
input
=
open_cloexec
(
fd
->
path
,
O_RDONLY
|
O_NONBLOCK
,
0
);
fd
->
input
=
open_cloexec
(
fd
->
path
,
O_RDONLY
|
O_NONBLOCK
|
O_BINARY
,
0
);
if
(
fd
->
input
<
0
)
{
g_set_error
(
error
,
fifo_output_quark
(),
errno
,
"Could not open FIFO
\"
%s
\"
for reading: %s"
,
...
...
@@ -163,7 +163,7 @@ fifo_open(struct fifo_data *fd, GError **error)
return
false
;
}
fd
->
output
=
open_cloexec
(
fd
->
path
,
O_WRONLY
|
O_NONBLOCK
,
0
);
fd
->
output
=
open_cloexec
(
fd
->
path
,
O_WRONLY
|
O_NONBLOCK
|
O_BINARY
,
0
);
if
(
fd
->
output
<
0
)
{
g_set_error
(
error
,
fifo_output_quark
(),
errno
,
"Could not open FIFO
\"
%s
\"
for writing: %s"
,
...
...
src/output/recorder_output_plugin.c
View file @
c727e869
...
...
@@ -22,11 +22,11 @@
#include "encoder_plugin.h"
#include "encoder_list.h"
#include "fd_util.h"
#include "open.h"
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
...
...
@@ -158,7 +158,8 @@ recorder_output_open(void *data, struct audio_format *audio_format,
/* create the output file */
recorder
->
fd
=
open_cloexec
(
recorder
->
path
,
O_CREAT
|
O_WRONLY
|
O_TRUNC
,
recorder
->
fd
=
open_cloexec
(
recorder
->
path
,
O_CREAT
|
O_WRONLY
|
O_TRUNC
|
O_BINARY
,
0666
);
if
(
recorder
->
fd
<
0
)
{
g_set_error
(
error_r
,
recorder_output_quark
(),
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