summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2016-11-26 22:17:01 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2016-11-26 22:42:20 +0900
commite4f3d633c1823beb09ac7a9671b72b6c9472e251 (patch)
tree9b3249a3d5dab5f2534f8419934ed3bac620a67c
parentd0a0645836e2221148200d2da0ae9166f59f6bc3 (diff)
Use stdin for *NIX as well
We thought that we can use /dev/stdin for *NIX, but some variants, like Android, does not have one or root permission is required. Just like we do for Windows build, we just use stdin if /dev/stdin is used.
-rw-r--r--src/BufferedFile.cc12
-rw-r--r--src/GZipFile.cc11
2 files changed, 12 insertions, 11 deletions
diff --git a/src/BufferedFile.cc b/src/BufferedFile.cc
index 3618f439..267fe3f3 100644
--- a/src/BufferedFile.cc
+++ b/src/BufferedFile.cc
@@ -44,15 +44,15 @@
namespace aria2 {
BufferedFile::BufferedFile(const char* filename, const char* mode)
- :
-#ifdef __MINGW32__
- fp_(strcmp(DEV_STDIN, filename) == 0
+ : fp_(strcmp(DEV_STDIN, filename) == 0
? stdin
- : a2fopen(utf8ToWChar(filename).c_str(),
- utf8ToWChar(mode).c_str())),
+ :
+#ifdef __MINGW32__
+ a2fopen(utf8ToWChar(filename).c_str(), utf8ToWChar(mode).c_str())
#else // !__MINGW32__
- fp_(a2fopen(filename, mode)),
+ a2fopen(filename, mode)
#endif // !__MINGW32__
+ ),
supportsColor_(fp_ ? isatty(fileno(fp_)) : false)
{
}
diff --git a/src/GZipFile.cc b/src/GZipFile.cc
index 81673a58..80ef10ee 100644
--- a/src/GZipFile.cc
+++ b/src/GZipFile.cc
@@ -46,15 +46,16 @@ namespace aria2 {
GZipFile::GZipFile(const char* filename, const char* mode)
: fp_(nullptr), buflen_(1_k), buf_(reinterpret_cast<char*>(malloc(buflen_)))
{
- FILE* fp =
-#ifdef __MINGW32__
+ auto fp =
strcmp(DEV_STDIN, filename) == 0
? stdin
- : a2fopen(utf8ToWChar(filename).c_str(), utf8ToWChar(mode).c_str());
+ :
+#ifdef __MINGW32__
+ a2fopen(utf8ToWChar(filename).c_str(), utf8ToWChar(mode).c_str())
#else // !__MINGW32__
- a2fopen(filename, mode);
+ a2fopen(filename, mode)
#endif // !__MINGW32__
-
+ ;
if (fp) {
int fd = dup(fileno(fp));
if (fd != -1) {