From b5cf75afd1b1d52cda6a3595fc8a3566aa5432bf Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sun, 17 Jun 2018 20:52:11 -0400 Subject: [PATCH] Handle filepaths better This change lops off any filename portion of a path and attempts to verify that it is a valid Uru directory. --- korman/operators/op_world.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/korman/operators/op_world.py b/korman/operators/op_world.py index 86e9f39..7affe66 100644 --- a/korman/operators/op_world.py +++ b/korman/operators/op_world.py @@ -36,9 +36,10 @@ class GameAddOperator(AgeOperator, bpy.types.Operator): if w: # First, verify this is a valid Uru directory... path = Path(self.filepath) + + # Blendsucks likes to tack filenames onto our doggone directories... if not path.is_dir(): - self.report({"ERROR"}, "The selection is not a valid directory.") - return {"CANCELLED"} + path = path.parent if not ((path / "UruExplorer.exe").is_file() or (path / "plClient.exe").is_file()): self.report({"ERROR"}, "The selected directory is not a copy of URU.") return {"CANCELLED"} @@ -53,7 +54,7 @@ class GameAddOperator(AgeOperator, bpy.types.Operator): game = games.games[self.game_index] # Setup game... - game.path = self.filepath + game.path = str(path) if (path / "cypython22.dll").is_file(): game.version = "pvPots" else: