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

Function detect_mobile_web_dir

src/apps/desktop/src/api/remote_connect_api.rs:103–135  ·  view source on GitHub ↗

Auto-detect the mobile-web build output directory.

()

Source from the content-addressed store, hash-verified

101
102/// Auto-detect the mobile-web build output directory.
103fn detect_mobile_web_dir() -> Option<String> {
104 if let Ok(dir) = std::env::var("BITFUN_MOBILE_WEB_DIR") {
105 let p = std::path::Path::new(&dir);
106 if p.join("index.html").exists() {
107 log::info!("Using BITFUN_MOBILE_WEB_DIR: {dir}");
108 return Some(dir);
109 }
110 log::warn!("BITFUN_MOBILE_WEB_DIR set but index.html not found: {dir}");
111 }
112
113 if let Some(resource_path) = MOBILE_WEB_RESOURCE_PATH.get() {
114 if is_valid_mobile_web_dir(resource_path) {
115 let dir = resource_path.to_string_lossy().into_owned();
116 log::info!("Using Tauri bundled mobile-web: {dir}");
117 return Some(dir);
118 }
119 log::debug!(
120 "Tauri resource path registered but not a valid mobile-web dir: {}",
121 resource_path.display()
122 );
123 }
124
125 if let Some(dir) = detect_from_exe() {
126 return Some(dir);
127 }
128
129 if let Some(dir) = detect_from_cwd() {
130 return Some(dir);
131 }
132
133 log::warn!("mobile-web dist directory not found; LAN/Ngrok modes will not serve static files");
134 None
135}
136
137fn detect_from_exe() -> Option<String> {
138 let exe = std::env::current_exe().ok()?;

Callers 2

ensure_serviceFunction · 0.85

Calls 6

is_valid_mobile_web_dirFunction · 0.85
detect_from_exeFunction · 0.85
detect_from_cwdFunction · 0.85
existsMethod · 0.45
joinMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected