MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / InputStream

Method InputStream

tools/ktx/command.cpp:96–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94// -------------------------------------------------------------------------------------------------
95
96InputStream::InputStream(const std::string& filepath, Reporter& report) :
97 filepath(filepath) {
98 if (filepath == "-") {
99 #if defined(_WIN32)
100 // Set "stdin" to binary mode
101 const auto setmodeResult = _setmode(_fileno(stdin), _O_BINARY);
102 if (setmodeResult == -1)
103 report.fatal(rc::IO_FAILURE, "Failed to set stdin mode to binary: {}.", setmodeResult);
104 // #else
105 // std::freopen(nullptr, "rb", stdin);
106 #endif
107
108 // Read everything from stdin into memory to enable random access
109 stdinBuffer << std::cin.rdbuf();
110 activeStream = &stdinBuffer;
111 } else {
112 file.open(DecodeUTF8Path(filepath).c_str(), std::ios::binary | std::ios::in);
113 if (!file)
114 report.fatal(rc::IO_FAILURE, "Could not open input file \"{}\": {}.", filepath, errnoMessage());
115 activeStream = &file;
116 }
117}
118
119// -------------------------------------------------------------------------------------------------
120

Callers

nothing calls this directly

Calls 5

errnoMessageFunction · 0.70
DecodeUTF8PathFunction · 0.50
fatalMethod · 0.45
openMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected