MCPcopy Create free account
hub / github.com/GCWing/BitFun / stat_local_path_metadata

Function stat_local_path_metadata

src/apps/desktop/src/api/path_target.rs:184–214  ·  view source on GitHub ↗
(
    requested_path: &str,
    resolved_path: &Path,
    is_runtime_artifact: bool,
)

Source from the content-addressed store, hash-verified

182}
183
184pub fn stat_local_path_metadata(
185 requested_path: &str,
186 resolved_path: &Path,
187 is_runtime_artifact: bool,
188) -> Result<LocalFileMetadata, String> {
189 let metadata = std::fs::metadata(resolved_path).map_err(|e| {
190 format!(
191 "Failed to stat local file '{}': {}",
192 resolved_path.display(),
193 e
194 )
195 })?;
196
197 let modified = metadata
198 .modified()
199 .unwrap_or(SystemTime::UNIX_EPOCH)
200 .duration_since(SystemTime::UNIX_EPOCH)
201 .unwrap_or_default()
202 .as_millis() as u64;
203
204 Ok(LocalFileMetadata {
205 path: requested_path.to_string(),
206 resolved_path: is_runtime_artifact.then(|| resolved_path.to_string_lossy().to_string()),
207 modified,
208 size: metadata.len(),
209 is_file: metadata.is_file(),
210 is_dir: metadata.is_dir(),
211 is_remote: Some(false),
212 is_runtime_artifact: is_runtime_artifact.then_some(true),
213 })
214}
215
216pub async fn read_text_file(
217 app_state: &AppState,

Callers 1

get_path_metadataFunction · 0.85

Calls 4

metadataFunction · 0.50
lenMethod · 0.45
is_fileMethod · 0.45
is_dirMethod · 0.45

Tested by

no test coverage detected