Spaces:
Running
Running
main : set stdin to binary mode on Windows (#2025)
Browse files- examples/common.cpp +9 -0
examples/common.cpp
CHANGED
|
@@ -19,6 +19,11 @@
|
|
| 19 |
#pragma warning(disable: 4244 4267) // possible loss of data
|
| 20 |
#endif
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
// Function to check if the next argument exists
|
| 23 |
std::string get_next_arg(int& i, int argc, char** argv, const std::string& flag, gpt_params& params) {
|
| 24 |
if (i + 1 < argc && argv[i + 1][0] != '-') {
|
|
@@ -636,6 +641,10 @@ bool read_wav(const std::string & fname, std::vector<float>& pcmf32, std::vector
|
|
| 636 |
|
| 637 |
if (fname == "-") {
|
| 638 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
| 639 |
uint8_t buf[1024];
|
| 640 |
while (true)
|
| 641 |
{
|
|
|
|
| 19 |
#pragma warning(disable: 4244 4267) // possible loss of data
|
| 20 |
#endif
|
| 21 |
|
| 22 |
+
#ifdef _WIN32
|
| 23 |
+
#include <fcntl.h>
|
| 24 |
+
#include <io.h>
|
| 25 |
+
#endif
|
| 26 |
+
|
| 27 |
// Function to check if the next argument exists
|
| 28 |
std::string get_next_arg(int& i, int argc, char** argv, const std::string& flag, gpt_params& params) {
|
| 29 |
if (i + 1 < argc && argv[i + 1][0] != '-') {
|
|
|
|
| 641 |
|
| 642 |
if (fname == "-") {
|
| 643 |
{
|
| 644 |
+
#ifdef _WIN32
|
| 645 |
+
_setmode(_fileno(stdin), _O_BINARY);
|
| 646 |
+
#endif
|
| 647 |
+
|
| 648 |
uint8_t buf[1024];
|
| 649 |
while (true)
|
| 650 |
{
|