#include #include #include #include #include #include #include #include "Input.h" #include "Exceptions.h" #include "config.h" Input::Input(String no) throw (GeneralException) : 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)); } cerr << "File " << no << " is opened with handle " << GetHandle() << endl; size = lseek(GetHandle(), 0, SEEK_END); lseek(GetHandle(), 0, SEEK_SET); struct stat s; fstat(GetHandle(), &s); date_modif = s.st_mtime; } bool Input::CanWrite() { return 0; } bool Input::CanRead() { return 1; } String Input::GetName() { return n; } off_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;