aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/streams/factory/open_common/factory.cpp
blob: c99ac441216a8c25316e143c4b6d3decb772c54e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "factory.h"

#include <util/stream/file.h>
#include <util/system/file.h>
#include <util/generic/ptr.h>

#ifdef _win_ // isatty
#include <io.h>
#else
#include <unistd.h>
#endif

THolder<IInputStream> OpenStdin(size_t bufSize) {
    if (isatty(0)) {
        return MakeHolder<TUnbufferedFileInput>(Duplicate(0));
    }
    return MakeHolder<TFileInput>(Duplicate(0), bufSize);
}