blob: 3f755ef40b033911ed12d704a1bbdab789d49d31 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#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;
|