#include <unistd.h>
#include <fcntl.h>

enum {
    buf_size = 4096
};

class File {
    int fd;
public:
    File() { fd = -1; }
    bool OpenRO(const char *name) {
        fd = open(name, O_RDONLY);
        return fd != -1;
    }
    int Read(char *buf, int size) { return read(fd, buf, buf_size); }
    ~File() { if (fd != -1) close(fd); }
};

int main()
{
    int rc;
    char buf[buf_size];
    File f;

    f.OpenRO("Makefile");

    for (;;) {
        rc = f.Read(buf, sizeof(buf));
        if (rc <= 0)
            break;
        write(1, buf, rc);
    }

    return 0;
}
