aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2014-05-24 14:06:18 +0200
committerGravatar wm4 <wm4@nowhere>2014-05-24 16:17:52 +0200
commit8665f7801837ac29f0171437e1c1cb7d6d51e410 (patch)
tree16b5a8aa7f1527630d58fb6690d57c0d58172ecb
parentaa87c143cb369f1448f8d08086b5ef98998b4436 (diff)
stream_file: readjust some windows ifdeffery
Also sneak in some cosmetics. setmode() exists on Windows/msvcrt only, so there's no need for a config test. I couldn't reproduce the problem with seekable pipes on wine, so axe it. (I'm aware that it still could be an issue on real Windows.)
-rwxr-xr-xold-configure1
-rw-r--r--stream/stream_file.c32
-rw-r--r--wscript4
3 files changed, 9 insertions, 28 deletions
diff --git a/old-configure b/old-configure
index 9700cc75b9..b160881871 100755
--- a/old-configure
+++ b/old-configure
@@ -947,7 +947,6 @@ cat > $TMPC << EOF
#define HAVE_DOS_PATHS 0
#define HAVE_PRIORITY 0
#define HAVE_GLOB 1
-#define HAVE_SETMODE 0
#define HAVE_POSIX_SELECT 1
#define HAVE_SYS_MMAN_H 1
#define HAVE_NANOSLEEP 1
diff --git a/stream/stream_file.c b/stream/stream_file.c
index a0ffc9114f..6b9c6d5471 100644
--- a/stream/stream_file.c
+++ b/stream/stream_file.c
@@ -91,9 +91,7 @@ static int control(stream_t *s, int cmd, void *arg)
struct priv *p = s->priv;
switch (cmd) {
case STREAM_CTRL_GET_SIZE: {
- off_t size;
-
- size = lseek(p->fd, 0, SEEK_END);
+ off_t size = lseek(p->fd, 0, SEEK_END);
lseek(p->fd, s->pos, SEEK_SET);
if (size != (off_t)-1) {
*(int64_t *)arg = size;
@@ -227,16 +225,13 @@ static int open_f(stream_t *stream)
if (!write) {
MP_INFO(stream, "Reading from stdin...\n");
fd = 0;
-#if HAVE_SETMODE
- setmode(fileno(stdin), O_BINARY);
-#endif
} else {
- MP_INFO(stream, "Writing to stdout\n");
+ MP_INFO(stream, "Writing to stdout...\n");
fd = 1;
-#if HAVE_SETMODE
- setmode(fileno(stdout), O_BINARY);
-#endif
}
+#ifdef __MINGW32__
+ setmode(fd, O_BINARY);
+#endif
priv->fd = fd;
priv->close = false;
} else {
@@ -250,34 +245,25 @@ static int open_f(stream_t *stream)
filename, strerror(errno));
return STREAM_ERROR;
}
-#ifndef __MINGW32__
struct stat st;
if (fstat(fd, &st) == 0 && S_ISDIR(st.st_mode)) {
MP_ERR(stream, "File is a directory: '%s'\n", filename);
close(fd);
return STREAM_ERROR;
}
-#endif
priv->fd = fd;
priv->close = true;
}
- int64_t len = lseek(fd, 0, SEEK_END);
+ off_t len = lseek(fd, 0, SEEK_END);
lseek(fd, 0, SEEK_SET);
-#ifdef __MINGW32__
- // seeks on stdin incorrectly succeed on MinGW
- if (fd == 0)
- len = -1;
-#endif
- stream->type = STREAMTYPE_FILE;
- stream->fast_skip = true;
- if (len >= 0) {
+ if (len != (off_t)-1) {
stream->seek = seek;
stream->seekable = true;
}
- MP_VERBOSE(stream, "File size is %" PRId64 " bytes\n", len);
-
+ stream->type = STREAMTYPE_FILE;
+ stream->fast_skip = true;
stream->fill_buffer = fill_buffer;
stream->write_buffer = write_buffer;
stream->control = control;
diff --git a/wscript b/wscript
index a5f156b93f..6a6369f99c 100644
--- a/wscript
+++ b/wscript
@@ -198,10 +198,6 @@ iconv support use --disable-iconv.",
'deps_any': [ 'os-win32', 'os-cygwin' ],
'func': check_true
}, {
- 'name': 'setmode',
- 'desc': 'setmode()',
- 'func': check_statement('io.h', 'setmode(0, 0)')
- }, {
'name': 'bsd-fstatfs',
'desc': "BSD's fstatfs()",
'func': check_statement(['sys/param.h', 'sys/mount.h'],