END_TEST START_TEST (test_rb_check_dir_has_space) { init_once (TRUE); fail_unless (rb_check_dir_has_space_uri ("file:///tmp", 1)); fail_unless (rb_check_dir_has_space_uri ("file:///etc/passwd", 1)); fail_unless (rb_check_dir_has_space_uri ("file:///tmp/NONEXISTANT_FILE", 1)); fail_unless (rb_check_dir_has_space_uri ("file:///tmp/NONEXISTANT/THISDOESNTEXISTEITHER/NORDOESTHIS", G_MAXUINT64) == FALSE); }
static gboolean rb_mtp_source_transfer_track_to_disk (LIBMTP_mtpdevice_t *device, LIBMTP_track_t *track, const char *uri) { int ret = -1; char *path; if (device == NULL || track == NULL || strlen (uri) == 0) { rb_debug ("device (%p), track (%p), or URI (%s) not supplied", device, track, uri); return FALSE; } if (rb_check_dir_has_space_uri (uri, track->filesize) == FALSE) { rb_debug ("not enough space to transfer track %d to %s", track->item_id, uri); return FALSE; } path = g_filename_from_uri (uri, NULL, NULL); if (path != NULL) { ret = LIBMTP_Get_Track_To_File (device, track->item_id, path, NULL, NULL); rb_debug ("LIBMTP_Get_Track_To_File(%d, %s) returned %d", track->item_id, path, ret); if (ret != 0) { report_libmtp_errors (device, TRUE); } g_free (path); } else { g_warning ("couldn't get path from URI %s", uri); } return (ret == 0); }