Get a specific File in the Project by its id NOTE: If the project has not been opened, it will be opened upon calling this. NOTE: If files have not been pulled, they will be pulled upon calling this.
(&self, id: S)
| 231 | /// NOTE: If the project has not been opened, it will be opened upon calling this. |
| 232 | /// NOTE: If files have not been pulled, they will be pulled upon calling this. |
| 233 | pub fn get_file_by_id<S: BnStrCompatible>(&self, id: S) -> Result<Option<Ref<RemoteFile>>, ()> { |
| 234 | // TODO: This sync should be removed? |
| 235 | if !self.has_pulled_files() { |
| 236 | self.pull_files()?; |
| 237 | } |
| 238 | let id = id.into_bytes_with_nul(); |
| 239 | let result = unsafe { |
| 240 | BNRemoteProjectGetFileById(self.handle.as_ptr(), id.as_ref().as_ptr() as *const c_char) |
| 241 | }; |
| 242 | Ok(NonNull::new(result).map(|handle| unsafe { RemoteFile::ref_from_raw(handle) })) |
| 243 | } |
| 244 | |
| 245 | /// Get a specific File in the Project by its name |
| 246 | /// |