TODO: AsRef Download a file from its remote, saving all snapshots to a database in the specified location. Returns a FileContext for opening the file later. `file` - Remote File to download and open `db_path` - File path for saved database `progress` - Function to call for progress updates
(
file: &RemoteFile,
db_path: S,
mut progress: F,
)
| 59 | /// * `db_path` - File path for saved database |
| 60 | /// * `progress` - Function to call for progress updates |
| 61 | pub fn download_file_with_progress<S: BnStrCompatible, F: ProgressCallback>( |
| 62 | file: &RemoteFile, |
| 63 | db_path: S, |
| 64 | mut progress: F, |
| 65 | ) -> Result<Ref<FileMetadata>, ()> { |
| 66 | let db_path = db_path.into_bytes_with_nul(); |
| 67 | let result = unsafe { |
| 68 | BNCollaborationDownloadFile( |
| 69 | file.handle.as_ptr(), |
| 70 | db_path.as_ref().as_ptr() as *const c_char, |
| 71 | Some(F::cb_progress_callback), |
| 72 | &mut progress as *mut F as *mut c_void, |
| 73 | ) |
| 74 | }; |
| 75 | let success = !result.is_null(); |
| 76 | success |
| 77 | .then(|| unsafe { Ref::new(FileMetadata::from_raw(result)) }) |
| 78 | .ok_or(()) |
| 79 | } |
| 80 | |
| 81 | /// Upload a file, with database, to the remote under the given project |
| 82 | /// |
no test coverage detected