Skip to content

armgit / gecko

Public Imported from GitHub
0

A GameCube/Wii emulator and debugger written in Rust.

files relative to cwd, not exe. accidentally cargo clean'd my save games lol

Layle8d63a8929112
diff --git a/crates/app/src/cache.rs b/crates/app/src/cache.rs
index b5308b0..4af742b 100644
--- a/crates/app/src/cache.rs
+++ b/crates/app/src/cache.rs
@@ -55,7 +55,7 @@ impl Default for LibraryCache {
}
pub fn cache_path() -> PathBuf {
- config::exe_relative(Path::new(CACHE_DIR).join(CACHE_FILE))
+ config::data_relative(Path::new(CACHE_DIR).join(CACHE_FILE))
}
pub fn load(path: &Path) -> LibraryCache {
diff --git a/crates/app/src/config.rs b/crates/app/src/config.rs
index f50cab8..0184014 100644
--- a/crates/app/src/config.rs
+++ b/crates/app/src/config.rs
@@ -184,7 +184,7 @@ impl Default for Config {
}
}
-/// Console-internal storage (SRAM, memory cards) lives next to the binary.
+/// Console-internal storage (SRAM, memory cards) lives in the data directory.
pub const SRAM_FILE: &str = "internal/sram.bin";
pub const MEMCARD_A_FILE: &str = "internal/memcard_a.raw";
@@ -194,7 +194,7 @@ pub const IPL_FILE: &str = "IPL.bin";
impl Config {
pub fn system_dir_resolved(&self) -> PathBuf {
- self.system_dir.clone().unwrap_or_else(|| self::exe_relative("system"))
+ self.system_dir.clone().unwrap_or_else(|| self::data_relative("system"))
}
pub fn resolve_in_dir(override_path: &Option<PathBuf>, system_dir: &Path, name: &str) -> Option<PathBuf> {
@@ -206,12 +206,12 @@ impl Config {
}
}
-pub fn exe_relative(rel: impl AsRef<Path>) -> PathBuf {
+pub fn data_relative(rel: impl AsRef<Path>) -> PathBuf {
gecko::paths::resolve(rel)
}
pub fn config_path() -> PathBuf {
- self::exe_relative("config.toml")
+ self::data_relative("config.toml")
}
pub fn load(path: &Path) -> Config {
diff --git a/crates/app/src/player/state.rs b/crates/app/src/player/state.rs
index 54f0a79..ef85793 100644
--- a/crates/app/src/player/state.rs
+++ b/crates/app/src/player/state.rs
@@ -97,8 +97,8 @@ impl PlayerState {
coef_path: coef,
ipl_path: ipl,
skip_ipl: config.skip_ipl,
- sram_path: config.sram_enabled.then(|| config::exe_relative(SRAM_FILE)),
- memcard_path: config.memcard_enabled.then(|| config::exe_relative(MEMCARD_A_FILE)),
+ sram_path: config.sram_enabled.then(|| config::data_relative(SRAM_FILE)),
+ memcard_path: config.memcard_enabled.then(|| config::data_relative(MEMCARD_A_FILE)),
execution_mode: config.cpu_mode.into(),
input_config: config.input.clone(),
})),
diff --git a/crates/gecko/src/paths.rs b/crates/gecko/src/paths.rs
index 172a29e..edc97fd 100644
--- a/crates/gecko/src/paths.rs
+++ b/crates/gecko/src/paths.rs
@@ -13,10 +13,7 @@ pub fn base() -> &'static Path {
return PathBuf::from(custom);
}
- std::env::current_exe()
- .ok()
- .and_then(|exe| exe.parent().map(Path::to_path_buf))
- .unwrap_or_else(|| PathBuf::from("."))
+ std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."))
})
}