Ejemplo n.º 1
0
static csync_vio_method_handle_t *owncloud_creat(const char *durl, mode_t mode) {

    csync_vio_method_handle_t *handle = owncloud_open(durl, O_CREAT|O_WRONLY|O_TRUNC, mode);

    /* on create, the file needs to be created empty */
    owncloud_write( handle, NULL, 0 );

    return handle;
}
Ejemplo n.º 2
0
static void download_a_file( const char* local, void **state, const char *durl)
{
    char buffer[BUFSIZE+1];
    char path[256];
    char src_path[256];
    int  did;
    _TCHAR tlocal[256];

    csync_vio_method_handle_t *handle;
    ssize_t count;
    ssize_t overall_size = 0;
    csync_stat_t sb;

    /* Create the target path */
    strcpy( path, _credentials.oc_server );
    strcat( path, "/");
    strcat( path, (const char*) *state );
    strcat( path, "/");
    strcat( path, durl );

    strcpy( tlocal, "/tmp/");
    strcat( tlocal, local );
    did = _topen(tlocal, O_RDWR|O_CREAT, 0644);
    assert_true( did > -1 );

    handle = owncloud_open( path, O_RDONLY, 0644 );
    assert_int_not_equal( handle, NULL );

    while( (count = owncloud_read(handle, buffer, BUFSIZE)) > 0 ) {
        write( did, buffer, count );
        overall_size += count;
    }
    assert_int_equal( owncloud_close(handle), 0 );
    close(did);

    strcpy(src_path, TESTFILES_DIR);
    strcat(src_path, local);
    stat_local_file( &sb, src_path );

    /* assert the download size, it has to be the same. */
    assert_true( overall_size == sb.st_size );

}