llvm.org GIT mirror llvm / b92cb30
Support/Program: Make Change<stream>ToBinary return error_code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146522 91177308-0d34-0410-b5e6-96231b3b80d8 Michael J. Spencer 8 years ago
5 changed file(s) with 41 addition(s) and 32 deletion(s). Raw diff Collapse all Expand all
1616 #include "llvm/Support/Path.h"
1717
1818 namespace llvm {
19 class error_code;
1920 namespace sys {
2021
2122 // TODO: Add operations to communicate with the process, redirect its I/O,
121122 /// @brief Construct a Program by finding it by name.
122123 static Path FindProgramByName(const std::string& name);
123124
124 // These methods change the specified standard stream (stdin,
125 // stdout, or stderr) to binary mode. They return true if an error
126 // occurred
127 static bool ChangeStdinToBinary();
128 static bool ChangeStdoutToBinary();
129 static bool ChangeStderrToBinary();
125 // These methods change the specified standard stream (stdin, stdout, or
126 // stderr) to binary mode. They return errc::success if the specified stream
127 // was changed. Otherwise a platform dependent error is returned.
128 static error_code ChangeStdinToBinary();
129 static error_code ChangeStdoutToBinary();
130 static error_code ChangeStderrToBinary();
130131
131132 /// A convenience function equivalent to Program prg; prg.Execute(..);
132133 /// prg.Wait(..);
1212
1313 #include "llvm/Support/Program.h"
1414 #include "llvm/Config/config.h"
15 #include "llvm/Support/system_error.h"
1516 using namespace llvm;
1617 using namespace sys;
1718
411411 return false;
412412 }
413413
414 bool Program::ChangeStdinToBinary(){
414 error_code Program::ChangeStdinToBinary(){
415415 // Do nothing, as Unix doesn't differentiate between text and binary.
416 return false;
417 }
418
419 bool Program::ChangeStdoutToBinary(){
416 return make_error_code(errc::success);
417 }
418
419 error_code Program::ChangeStdoutToBinary(){
420420 // Do nothing, as Unix doesn't differentiate between text and binary.
421 return false;
422 }
423
424 bool Program::ChangeStderrToBinary(){
421 return make_error_code(errc::success);
422 }
423
424 error_code Program::ChangeStderrToBinary(){
425425 // Do nothing, as Unix doesn't differentiate between text and binary.
426 return false;
427 }
428
429 }
426 return make_error_code(errc::success);
427 }
428
429 }
396396 return false;
397397 }
398398
399 bool Program::ChangeStdinToBinary(){
399 error_code Program::ChangeStdinToBinary(){
400400 int result = _setmode( _fileno(stdin), _O_BINARY );
401 return result == -1;
402 }
403
404 bool Program::ChangeStdoutToBinary(){
401 if (result == -1)
402 return error_code(errno, generic_category());
403 return make_error_code(errc::success);
404 }
405
406 error_code Program::ChangeStdoutToBinary(){
405407 int result = _setmode( _fileno(stdout), _O_BINARY );
406 return result == -1;
407 }
408
409 bool Program::ChangeStderrToBinary(){
408 if (result == -1)
409 return error_code(errno, generic_category());
410 return make_error_code(errc::success);
411 }
412
413 error_code Program::ChangeStderrToBinary(){
410414 int result = _setmode( _fileno(stderr), _O_BINARY );
411 return result == -1;
412 }
413
414 }
415 if (result == -1)
416 return error_code(errno, generic_category());
417 return make_error_code(errc::success);
418 }
419
420 }
1919 #include "llvm/Config/config.h"
2020 #include "llvm/Support/Compiler.h"
2121 #include "llvm/Support/ErrorHandling.h"
22 #include "llvm/Support/system_error.h"
2223 #include "llvm/ADT/STLExtras.h"
2324 #include
2425 #include