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

Method resolve_destination

atomic-cli/src/commands/mv.rs:156–169  ·  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

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