Logo Search packages:      
Sourcecode: akode version File versions  Download package

bool aKode::MMapFile::openRO (  )  [virtual]

Opens the file as read-only. Returns whether the operation was succesfull.

Reimplemented from aKode::File.

Definition at line 56 of file mmapfile.cpp.

References close(), and aKode::File::filename.

                      {
    if(handle) return true;
    struct stat stat;

    fd = ::open(filename, O_RDONLY);
    if (fstat(fd, &stat) < 0) return false;
    len = stat.st_size;
    pos = 0;

    handle = mmap(0, len, PROT_READ, MAP_SHARED, fd, 0);
    if (handle == MAP_FAILED) {
        ::close(fd);
        handle = 0;
        return false;
    }

    return true;
}


Generated by  Doxygen 1.6.0   Back to index