MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / resolve_destination

Method resolve_destination

atomic-cli/src/commands/mv.rs:155–168  ·  view source on GitHub ↗

Resolve the destination path. If destination is a directory, append the source filename.

(&self, repo_root: &Path, source: &str, dest: &str)

Source from the content-addressed store, hash-verified

153 ///
154 /// If destination is a directory, append the source filename.
155 fn resolve_destination(&self, repo_root: &Path, source: &str, dest: &str) -> String {
156 let dest_path = repo_root.join(dest);
157
158 // If destination is an existing directory, move INTO it
159 if dest_path.is_dir() {
160 let source_name = Path::new(source)
161 .file_name()
162 .map(|n| n.to_string_lossy().to_string())
163 .unwrap_or_else(|| source.to_string());
164 format!("{}/{}", dest.trim_end_matches('/'), source_name)
165 } else {
166 dest.to_string()
167 }
168 }
169
170 /// Move the actual file on disk.
171 fn move_file_on_disk(&self, repo_root: &Path, from: &str, to: &str) -> std::io::Result<()> {

Calls 2

is_dirMethod · 0.80
file_nameMethod · 0.45