blob: a9d8c2b531114861b607b9b5bb5d3ef7d4c95c54 (
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
|
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
class File {
int descriptor;
public:
File(const char *filepath, int flags) {
descriptor = open(filepath, flags);
}
File(const char *filepath, int flags, mode_t mode) {
descriptor = open(filepath, flags, mode);
}
size_t send(void *msg, size_t length) {
return write(descriptor, msg, length);
}
size_t recv(void *msg, size_t length) {
return read(descriptor, msg, length);
}
~File() {
close(descriptor);
}
};
|