Get a specific File in the Project by its name 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,
name: S,
)
| 247 | /// NOTE: If the project has not been opened, it will be opened upon calling this. |
| 248 | /// NOTE: If files have not been pulled, they will be pulled upon calling this. |
| 249 | pub fn get_file_by_name<S: BnStrCompatible>( |
| 250 | &self, |
| 251 | name: S, |
| 252 | ) -> Result<Option<Ref<RemoteFile>>, ()> { |
| 253 | // TODO: This sync should be removed? |
| 254 | if !self.has_pulled_files() { |
| 255 | self.pull_files()?; |
| 256 | } |
| 257 | let id = name.into_bytes_with_nul(); |
| 258 | let result = unsafe { |
| 259 | BNRemoteProjectGetFileByName( |
| 260 | self.handle.as_ptr(), |
| 261 | id.as_ref().as_ptr() as *const c_char, |
| 262 | ) |
| 263 | }; |
| 264 | Ok(NonNull::new(result).map(|handle| unsafe { RemoteFile::ref_from_raw(handle) })) |
| 265 | } |
| 266 | |
| 267 | /// Pull the list of files from the Remote. |
| 268 | /// |
nothing calls this directly
no test coverage detected