forked from OSchip/llvm-project
Support/Program: Make Change<stream>ToBinary return error_code.
llvm-svn: 146522
This commit is contained in:
parent
7dfbeda68e
commit
a2755f8efa
|
@ -17,6 +17,7 @@
|
||||||
#include "llvm/Support/Path.h"
|
#include "llvm/Support/Path.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
class error_code;
|
||||||
namespace sys {
|
namespace sys {
|
||||||
|
|
||||||
// TODO: Add operations to communicate with the process, redirect its I/O,
|
// TODO: Add operations to communicate with the process, redirect its I/O,
|
||||||
|
@ -122,12 +123,12 @@ namespace sys {
|
||||||
/// @brief Construct a Program by finding it by name.
|
/// @brief Construct a Program by finding it by name.
|
||||||
static Path FindProgramByName(const std::string& name);
|
static Path FindProgramByName(const std::string& name);
|
||||||
|
|
||||||
// These methods change the specified standard stream (stdin,
|
// These methods change the specified standard stream (stdin, stdout, or
|
||||||
// stdout, or stderr) to binary mode. They return true if an error
|
// stderr) to binary mode. They return errc::success if the specified stream
|
||||||
// occurred
|
// was changed. Otherwise a platform dependent error is returned.
|
||||||
static bool ChangeStdinToBinary();
|
static error_code ChangeStdinToBinary();
|
||||||
static bool ChangeStdoutToBinary();
|
static error_code ChangeStdoutToBinary();
|
||||||
static bool ChangeStderrToBinary();
|
static error_code ChangeStderrToBinary();
|
||||||
|
|
||||||
/// A convenience function equivalent to Program prg; prg.Execute(..);
|
/// A convenience function equivalent to Program prg; prg.Execute(..);
|
||||||
/// prg.Wait(..);
|
/// prg.Wait(..);
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include "llvm/Support/Program.h"
|
#include "llvm/Support/Program.h"
|
||||||
#include "llvm/Config/config.h"
|
#include "llvm/Config/config.h"
|
||||||
|
#include "llvm/Support/system_error.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
using namespace sys;
|
using namespace sys;
|
||||||
|
|
||||||
|
|
|
@ -412,19 +412,19 @@ Program::Kill(std::string* ErrMsg) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Program::ChangeStdinToBinary(){
|
error_code Program::ChangeStdinToBinary(){
|
||||||
// Do nothing, as Unix doesn't differentiate between text and binary.
|
// Do nothing, as Unix doesn't differentiate between text and binary.
|
||||||
return false;
|
return make_error_code(errc::success);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Program::ChangeStdoutToBinary(){
|
error_code Program::ChangeStdoutToBinary(){
|
||||||
// Do nothing, as Unix doesn't differentiate between text and binary.
|
// Do nothing, as Unix doesn't differentiate between text and binary.
|
||||||
return false;
|
return make_error_code(errc::success);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Program::ChangeStderrToBinary(){
|
error_code Program::ChangeStderrToBinary(){
|
||||||
// Do nothing, as Unix doesn't differentiate between text and binary.
|
// Do nothing, as Unix doesn't differentiate between text and binary.
|
||||||
return false;
|
return make_error_code(errc::success);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -397,19 +397,25 @@ Program::Kill(std::string* ErrMsg) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Program::ChangeStdinToBinary(){
|
error_code Program::ChangeStdinToBinary(){
|
||||||
int result = _setmode( _fileno(stdin), _O_BINARY );
|
int result = _setmode( _fileno(stdin), _O_BINARY );
|
||||||
return result == -1;
|
if (result == -1)
|
||||||
|
return error_code(errno, generic_category());
|
||||||
|
return make_error_code(errc::success);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Program::ChangeStdoutToBinary(){
|
error_code Program::ChangeStdoutToBinary(){
|
||||||
int result = _setmode( _fileno(stdout), _O_BINARY );
|
int result = _setmode( _fileno(stdout), _O_BINARY );
|
||||||
return result == -1;
|
if (result == -1)
|
||||||
|
return error_code(errno, generic_category());
|
||||||
|
return make_error_code(errc::success);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Program::ChangeStderrToBinary(){
|
error_code Program::ChangeStderrToBinary(){
|
||||||
int result = _setmode( _fileno(stderr), _O_BINARY );
|
int result = _setmode( _fileno(stderr), _O_BINARY );
|
||||||
return result == -1;
|
if (result == -1)
|
||||||
|
return error_code(errno, generic_category());
|
||||||
|
return make_error_code(errc::success);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "llvm/Config/config.h"
|
#include "llvm/Config/config.h"
|
||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
|
#include "llvm/Support/system_error.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
|
Loading…
Reference in New Issue