#include #include #include #include #include #include #include #include "Output.h" #include "Exceptions.h" #include "config.h" Output::Output(String no, int trunc = 1) throw (GeneralException) : Handle(no.strlen() ? open(no.to_charp(), O_WRONLY | O_CREAT | (trunc ? O_TRUNC : O_APPEND)) : 1), n(no) { if (GetHandle() < 0) { throw IOGeneral(String("Error opening file") + no + " for writing: " + strerror(errno)); } } bool Output::CanWrite() { return 1; } bool Output::CanRead() { return 0; } String Output::GetName() { return n; } Stdout_t::Stdout_t() : Handle(dup(1)) {} bool Stdout_t::CanWrite() { return 1; } bool Stdout_t::CanRead() { return 0; } String Stdout_t::GetName() { return "Stdout"; } Stderr_t::Stderr_t() : Handle(dup(2)) {} bool Stderr_t::CanWrite() { return 1; } bool Stderr_t::CanRead() { return 0; } String Stderr_t::GetName() { return "Stderr"; } Stdout_t Stdout; Stderr_t Stderr;