pub async fn add_source_filename_to_path_if_absent<D: Directory>(
    destination_dir: &D,
    source_path: &PathBuf,
    destination_path: &PathBuf
) -> Result<PathBuf>
Expand description

If destination_path in destination_dir is itself a directory, returns a path with the filename portion of source_path appended. Otherwise, returns a copy of the input destination_path.

The purpose of this function is to help infer a path in cases which an ending file name for the destination path is not provided. For example, the command “ffx component storage copy ~/alarm.wav [instance-id]::/” does not know what name to give the new file copied. [instance-id]::/. Thus it is necessary to infer this new file name and generate the new path “[instance-id]::/alarm.wav”.

§Arguments

  • destination_dir: Directory to query for the type of destination_path
  • source_path: path from which to read a filename, if needed
  • destination_path: destination path

§Error Conditions:

  • File name for source_path is empty
  • Communications error talking to remote endpoint