Beispiel #1
0
static couch_file_handle couch_constructor(couchstore_error_info_t *errinfo,
                                           void* cookie)
{
    (void) cookie;
    /*  We don't have a file descriptor till couch_open runs,
        so return an invalid value for now. */
    return handle_to_win(INVALID_HANDLE_VALUE);
}
Beispiel #2
0
static off_t couch_goto_eof(couch_file_handle handle)
{
    HANDLE file = handle_to_win(handle);
    LARGE_INTEGER size;
    if(!GetFileSizeEx(file, &size)) {
        save_windows_error();
        return (off_t) COUCHSTORE_ERROR_READ;
    }
    return size.QuadPart;
}
Beispiel #3
0
static couchstore_error_t couch_sync(couch_file_handle handle)
{
    HANDLE file = handle_to_win(handle);

    if (!FlushFileBuffers(file)) {
        save_windows_error();
        return COUCHSTORE_ERROR_WRITE;
    }

    return COUCHSTORE_SUCCESS;
}
Beispiel #4
0
static ssize_t couch_pread(couch_file_handle handle, void *buf, size_t nbyte, off_t offset)
{
#ifdef LOG_IO
    fprintf(stderr, "PREAD  %8llx -- %8llx  (%6.1f kbytes)\n", offset, offset+nbyte, nbyte/1024.0);
#endif
    HANDLE file = handle_to_win(handle);
    BOOL rv;
    DWORD bytesread;
    OVERLAPPED winoffs;
    memset(&winoffs, 0, sizeof(winoffs));
    winoffs.Offset = offset & 0xFFFFFFFF;
    winoffs.OffsetHigh = offset >> 32;
    rv = ReadFile(file, buf, nbyte, &bytesread, &winoffs);
    if(!rv) {
        return (ssize_t) COUCHSTORE_ERROR_READ;
    }
    return bytesread;
}
Beispiel #5
0
static ssize_t couch_pwrite(couch_file_handle handle, const void *buf, size_t nbyte, off_t offset)
{
#ifdef LOG_IO
    fprintf(stderr, "PWRITE %8llx -- %8llx  (%6.1f kbytes)\n", offset, offset+nbyte, nbyte/1024.0);
#endif
    HANDLE file = handle_to_win(handle);
    BOOL rv;
    DWORD byteswritten;
    OVERLAPPED winoffs;
    memset(&winoffs, 0, sizeof(winoffs));
    winoffs.Offset = offset & 0xFFFFFFFF;
    winoffs.OffsetHigh = offset >> 32;
    rv = WriteFile(file, buf, nbyte, &byteswritten, &winoffs);
    if(!rv) {
        save_windows_error();
        return (ssize_t) COUCHSTORE_ERROR_WRITE;
    }
    return byteswritten;
}
Beispiel #6
0
static void couch_close(couch_file_handle handle)
{
    HANDLE file = handle_to_win(handle);
    CloseHandle(handle);
}
Beispiel #7
0
static couch_file_handle couch_constructor(void* cookie)
{
    (void) cookie;
    // We don't have a file descriptor till couch_open runs, so return an invalid value for now.
    return handle_to_win(INVALID_HANDLE_VALUE);
}
Beispiel #8
0
static void couch_close(couchstore_error_info_t *errinfo,
                        couch_file_handle handle)
{
    HANDLE file = handle_to_win(handle);
    CloseHandle(handle);
}