blob: 99c4bae47d3e824b3dac0da6c7b8d1918ea038b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#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 (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));
}
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;
|