MCPcopy Create free account
hub / github.com/PerroEngine/Perro / quick_asset_stem

Function quick_asset_stem

perro_editor/res/scripts/assets/editor_assets.rs:1879–1914  ·  view source on GitHub ↗
(state: &EditorState, kind: &str)

Source from the content-addressed store, hash-verified

1877 if selected_key.is_some() {
1878 attach_material_to_selected_node(ctx, &out_path);
1879 } else {
1880 refresh_all(ctx);
1881 }
1882 }
1883 Err(err) => set_log(ctx, &format!("glb mat write fail\n{out_path}\n{err}")),
1884 }
1885 }
1886 Err(err) => set_log(ctx, &format!("glb mat fail\n{glb_path}\n{err}")),
1887 }
1888}
1889
1890pub fn active_gltf_asset_path(state: &EditorState) -> Option<String> {
1891 if is_gltf_path(&state.active_asset_path) {
1892 Some(state.active_asset_path.clone())
1893 } else if is_gltf_path(&state.active_glb_path) {
1894 Some(state.active_glb_path.clone())
1895 } else {
1896 None
1897 }
1898}
1899
1900pub fn glb_asset_stem(path: &str) -> String {
1901 sanitize_file_stem(
1902 Path::new(&editor_files::rel_label(path))
1903 .file_stem()
1904 .and_then(|value| value.to_str())
1905 .unwrap_or("glb"),
1906 )
1907}
1908
1909pub fn unique_res_path(project_root: &str, dir: &str, stem: &str, ext: &str) -> String {
1910 let dir = dir.trim_matches('/');
1911 for idx in 0..1000 {
1912 let suffix = if idx == 0 {
1913 String::new()
1914 } else {
1915 format!("_{idx}")
1916 };
1917 let path = format!("res://{dir}/{stem}{suffix}.{ext}");

Callers

nothing calls this directly

Calls 6

cached_scene_doc_sharedFunction · 0.85
cached_scene_nodeFunction · 0.85
sanitize_file_stemFunction · 0.85
rel_labelFunction · 0.85
key_name_or_idMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected