blob: ab51c9fec59da10d23a97718e1b2c1a7b8d2afd2 (
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
|
#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;
}
|