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

Method from_path

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

Detect format from a path.

(path: &Path)

Source from the content-addressed store, hash-verified

178
179 /// Detect format from a path.
180 pub fn from_path(path: &Path) -> Option<Self> {
181 let path_str = path.to_string_lossy().to_lowercase();
182
183 if path_str.ends_with(".tar.gz") || path_str.ends_with(".tgz") {
184 Some(Self::TarGz)
185 } else if path_str.ends_with(".tar") {
186 Some(Self::Tar)
187 } else if path_str.ends_with(".zip") {
188 Some(Self::Zip)
189 } else if path.is_dir() || !path.to_string_lossy().contains('.') {
190 Some(Self::Directory)
191 } else {
192 None
193 }
194 }
195
196 /// Check if this format requires compression.
197 pub fn is_compressed(&self) -> bool {

Callers

nothing calls this directly

Calls 2

is_dirMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected