コード例 #1
0
ファイル: os_win.c プロジェクト: abhinavdangeti/couchstore
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);
}
コード例 #2
0
ファイル: os_win.c プロジェクト: Damienkatz/couchstore
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;
}
コード例 #3
0
ファイル: os_win.c プロジェクト: Damienkatz/couchstore
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;
}
コード例 #4
0
ファイル: os_win.c プロジェクト: Damienkatz/couchstore
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;
}
コード例 #5
0
ファイル: os_win.c プロジェクト: Damienkatz/couchstore
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;
}
コード例 #6
0
ファイル: os_win.c プロジェクト: Damienkatz/couchstore
static void couch_close(couch_file_handle handle)
{
    HANDLE file = handle_to_win(handle);
    CloseHandle(handle);
}
コード例 #7
0
ファイル: os_win.c プロジェクト: Damienkatz/couchstore
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);
}
コード例 #8
0
ファイル: os_win.c プロジェクト: abhinavdangeti/couchstore
static void couch_close(couchstore_error_info_t *errinfo,
                        couch_file_handle handle)
{
    HANDLE file = handle_to_win(handle);
    CloseHandle(handle);
}