diff options
Diffstat (limited to 'generic/Input.cpp')
-rw-r--r-- | generic/Input.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/generic/Input.cpp b/generic/Input.cpp index b7ee99c..d415279 100644 --- a/generic/Input.cpp +++ b/generic/Input.cpp @@ -16,18 +16,23 @@ Input::Input(const String & no) throw (GeneralException) : Handle(no.strlen() ? open(no.to_charp(), O_RDONLY) : dup(0)), n(no) { + +#ifdef DEBUG + fprintf(stderr, "Opening file %s, Input at %p\n", no.to_charp(), this); +#endif + 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; + + if (S_ISREG(s.st_mode)) { + size = seek(0, SEEK_END); + seek(0, SEEK_SET); + } } Input::Input(const Input & i) : Handle(i), n(i.n), size(i.size), date_modif(i.date_modif) { @@ -63,11 +68,11 @@ time_t Input::GetModif() { off_t Input::seek(off_t offset, int whence) throw (GeneralException) { if ((itell = lseek(GetHandle(), offset, whence)) < 0) { - throw IOGeneral(String(_("Error seeking file ")) + n + _(": ") + strerror(errno)); + throw IOGeneral(String(_("Error seeking file ")) + GetName() + _(": ") + strerror(errno)); } #ifdef PARANOID_SEEK if (itell != lseek(GetHandle(), 0, SEEK_CUR)) { - throw IOGeneral(String(_("Error seeking file ")) + n + _(": the position does not match")); + throw IOGeneral(String(_("Error seeking file ")) + GetName() + _(": the position does not match")); } #endif return itell; |