Merge pull request #786 from aria2/use-stdin

Use stdin for *NIX as well
pull/798/head
Tatsuhiro Tsujikawa 2016-12-04 10:30:13 +09:00 committed by GitHub
commit b24a3c3c2e
2 changed files with 12 additions and 11 deletions

View File

@ -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)
{
}

View File

@ -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) {