diff options
Diffstat (limited to 'src/common/file.cpp')
-rw-r--r-- | src/common/file.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/common/file.cpp b/src/common/file.cpp new file mode 100644 index 0000000..a9d8c2b --- /dev/null +++ b/src/common/file.cpp @@ -0,0 +1,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); + } +}; |