summaryrefslogtreecommitdiff
path: root/generic/Input.cpp
diff options
context:
space:
mode:
authorPixel <Pixel>2002-08-25 14:39:48 +0000
committerPixel <Pixel>2002-08-25 14:39:48 +0000
commit38d60726082b04e79edae1c8c797c6dcb8314504 (patch)
tree4a056a158c6fc21c29dd8d8ed94c010a25cee19a /generic/Input.cpp
parent1b0a5db816b7610c83615e93095155b1709f55da (diff)
Workiiiiiiiiiiiiiiiiiing!!!!
Diffstat (limited to 'generic/Input.cpp')
-rw-r--r--generic/Input.cpp19
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;