summaryrefslogtreecommitdiff
path: root/lib/Input.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Input.cc')
-rw-r--r--lib/Input.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/Input.cc b/lib/Input.cc
new file mode 100644
index 0000000..f4e2602
--- /dev/null
+++ b/lib/Input.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 "Input.h"
+#include "Exceptions.h"
+#include "config.h"
+
+Input::Input(String no) throw (IOGeneral) :
+ Handle(no.strlen() ? open(no.to_charp(), O_RDONLY) : 0),
+ n(no) {
+ if (GetHandle() < 0) {
+ throw IOGeneral(String("Error opening file") + no + " for reading: " + strerror(errno));
+ }
+}
+
+bool Input::CanWrite() {
+ return 0;
+}
+
+bool Input::CanRead() {
+ return 1;
+}
+
+String Input::GetName() {
+ return n;
+}
+