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

Function ensure_extension

atomic-repository/src/archive.rs:806–818  ·  view source on GitHub ↗

Ensure a path ends with the appropriate extension for the format.

(path: &Path, format: ArchiveFormat)

Source from the content-addressed store, hash-verified

804
805/// Ensure a path ends with the appropriate extension for the format.
806pub fn ensure_extension(path: &Path, format: ArchiveFormat) -> PathBuf {
807 let ext = format.extension();
808 if ext.is_empty() {
809 return path.to_path_buf();
810 }
811
812 let path_str = path.to_string_lossy();
813 if path_str.ends_with(ext) {
814 path.to_path_buf()
815 } else {
816 PathBuf::from(format!("{}{}", path_str, ext))
817 }
818}
819
820/// Get the output path for an archive with optional prefix.
821pub fn get_archive_path(base: &Path, prefix: Option<&str>) -> PathBuf {

Callers

nothing calls this directly

Calls 2

extensionMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected