summaryrefslogtreecommitdiff
path: root/lib/Output.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Output.cc')
-rw-r--r--lib/Output.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/Output.cc b/lib/Output.cc
new file mode 100644
index 0000000..75bb437
--- /dev/null
+++ b/lib/Output.cc
@@ -0,0 +1,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 (IOGeneral) :
+ 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;
+}
+