diff options
author | Pixel <Pixel> | 2002-07-21 11:12:13 +0000 |
---|---|---|
committer | Pixel <Pixel> | 2002-07-21 11:12:13 +0000 |
commit | 6528f07c516efe4d3b344f01740067878d5d9a43 (patch) | |
tree | f097e6797752dffe7b498a4f153e83bdeb59f024 /generic/Input.cpp | |
parent | b54786a5120b48bd98fc4b199176d45bda3c2d67 (diff) |
Hello Baltisot
Diffstat (limited to 'generic/Input.cpp')
-rw-r--r-- | generic/Input.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/generic/Input.cpp b/generic/Input.cpp new file mode 100644 index 0000000..7106c8d --- /dev/null +++ b/generic/Input.cpp @@ -0,0 +1,70 @@ +#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" +#ifdef HAVE_CONFIG_H +#include "config.h" +#else +#define _(x) x +#endif + +Input::Input(String no) throw (GeneralException) : + Handle(no.strlen() ? open(no.to_charp(), O_RDONLY) : dup(0)), + n(no) { + if (GetHandle() < 0) { + throw IOGeneral(String(_("Error opening file ")) + no + _(" for reading: ") + strerror(errno)); + } + + size = lseek(GetHandle(), 0, SEEK_END); + lseek(GetHandle(), 0, SEEK_SET); + + struct stat s; + + fstat(GetHandle(), &s); + + date_modif = s.st_mtime; +} + +Input::Input(const Input & i) : Handle(i), n(i.n), size(i.size), date_modif(i.date_modif) { +} + +bool Input::CanWrite() { + return 0; +} + +bool Input::CanRead() { + return 1; +} + +String Input::GetName() { + return n; +} + +ssize_t Input::GetSize() { + return size; +} + +time_t Input::GetModif() { + return date_modif; +} + +Stdin_t::Stdin_t() : Handle(dup(0)) { } + +bool Stdin_t::CanWrite() { + return 0; +} + +bool Stdin_t::CanRead() { + return 1; +} + +String Stdin_t::GetName() { + return "Stdin"; +} + +Stdin_t Stdin; |