blob: 626f352adc0ff4c9eebde6d2712059fa707a9ae4 (
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
|
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
struct File {
int descriptor;
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);
}
};
|