factory.cpp 387 B

12345678910111213141516171819
  1. #include "factory.h"
  2. #include <util/stream/file.h>
  3. #include <util/system/file.h>
  4. #include <util/generic/ptr.h>
  5. #ifdef _win_ // isatty
  6. #include <io.h>
  7. #else
  8. #include <unistd.h>
  9. #endif
  10. THolder<IInputStream> OpenStdin(size_t bufSize) {
  11. if (isatty(0)) {
  12. return MakeHolder<TUnbufferedFileInput>(Duplicate(0));
  13. }
  14. return MakeHolder<TFileInput>(Duplicate(0), bufSize);
  15. }