aboutsummaryrefslogtreecommitdiff
path: root/src/world.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/world.rs')
-rw-r--r--src/world.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/world.rs b/src/world.rs
index 42a41a4..79ba3f9 100644
--- a/src/world.rs
+++ b/src/world.rs
@@ -37,8 +37,14 @@ impl World {
/// Returns the name of the world.
pub fn world_name(&self) -> Result<String> {
+ let fallback = self.path
+ .file_name()
+ .map(|s| s.to_str().expect("Non-UTF8 directory encountered"));
+
let conf = self.conf()?;
conf.get("world_name")
+ .map(String::as_str)
+ .or(fallback)
.ok_or_else(|| Error::InvalidWorldDir(self.path.clone()))
.map(Into::into)
}