Skip to content

Commit

Permalink
Rename vfs LocalData to UserData
Browse files Browse the repository at this point in the history
  • Loading branch information
manpat committed Oct 27, 2024
1 parent a9aed1f commit 178ed21
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion toybox-cfg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Config {
config.base = table::load_from_vfs(vfs, PathKind::Config, "config.toml")?;

} else {
log::info!("Couldn't load config - writing defaults to '{}'", vfs.local_data_root().display());
log::info!("Couldn't load config - writing defaults to '{}'", vfs.user_data_root().display());
// TODO(pat.m): defaults?
table::save_to_vfs(&config.base, vfs, PathKind::Config, "config.toml")?;
}
Expand Down
24 changes: 12 additions & 12 deletions toybox-vfs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub mod prelude {}
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
pub enum PathKind {
Resource,
LocalData,
UserData,

Config,
}
Expand All @@ -21,7 +21,7 @@ pub struct Vfs {
resource_root: Box<Path>,

// All inter-session data - game saves, user config, etc
local_data_root: Box<Path>,
user_data_root: Box<Path>,
}

impl Vfs {
Expand All @@ -31,33 +31,33 @@ impl Vfs {
.context("Can't find resource directory")?
.into_boxed_path();

let mut local_data_root = dirs::data_dir()
let mut user_data_root = dirs::data_dir()
.context("Can't find local data directory")?;

local_data_root.push("toybox");
local_data_root.push(app_name);
user_data_root.push("toybox");
user_data_root.push(app_name);

let local_data_root = local_data_root.into_boxed_path();
let user_data_root = user_data_root.into_boxed_path();

log::info!("Resource Root Path: {}", resource_root.display());
log::info!("Data Root Path: {}", local_data_root.display());
log::info!("Data Root Path: {}", user_data_root.display());

Ok(Vfs { resource_root, local_data_root })
Ok(Vfs { resource_root, user_data_root })
}

pub fn resource_root(&self) -> &Path {
&self.resource_root
}

pub fn local_data_root(&self) -> &Path {
&self.local_data_root
pub fn user_data_root(&self) -> &Path {
&self.user_data_root
}

fn resolve_root(&self, kind: PathKind) -> &Path {
match kind {
PathKind::Resource => &self.resource_root,
PathKind::LocalData => &self.local_data_root,
PathKind::Config => &self.local_data_root,
PathKind::UserData => &self.user_data_root,
PathKind::Config => &self.user_data_root,
}
}

Expand Down

0 comments on commit 178ed21

Please sign in to comment.