changeset 297:a09ac4650e0d

Fix relative path handling and os-specific path separators.
author Thibaut Girka <thib@sitedethib.com>
date Tue, 06 Mar 2012 17:45:14 +0100
parents c074783d0847
children 92a6fd2632f1
files eosd pytouhou/resource/loader.py
diffstat 2 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/eosd
+++ b/eosd
@@ -58,9 +58,10 @@ def main(path, stage_num, rank, characte
     runner.start()
 
 
-default_data = ('CM.DAT:th06*_CM.DAT:*CM.DAT:*cm.dat',
-                'ST.DAT:th6*ST.DAT:*ST.DAT:*st.dat',
-                '102h.exe:102*.exe:東方紅魔郷.exe:*.exe')
+pathsep = os.path.pathsep
+default_data = (pathsep.join(('CM.DAT', 'th06*_CM.DAT', '*CM.DAT', '*cm.dat')),
+                pathsep.join(('ST.DAT', 'th6*ST.DAT', '*ST.DAT', '*st.dat')),
+                pathsep.join(('102h.exe', '102*.exe', '東方紅魔郷.exe', '*.exe')))
 
 
 parser = argparse.ArgumentParser(description='Libre reimplementation of the Touhou 6 engine.')
--- a/pytouhou/resource/loader.py
+++ b/pytouhou/resource/loader.py
@@ -106,7 +106,7 @@ class Loader(object):
     def scan_archives(self, paths_lists):
         for paths in paths_lists:
             def _expand_paths():
-                for path in paths.split(':'):
+                for path in paths.split(os.path.pathsep):
                     if self.game_dir and not os.path.isabs(path):
                         path = os.path.join(self.game_dir, path)
                     yield glob(path)
@@ -170,8 +170,6 @@ class Loader(object):
     def get_eosd_characters(self):
         #TODO: Move to pytouhou.games.eosd?
         path = self.exe
-        if self.game_dir and not os.path.isabs(path):
-            path = os.path.join(self.game_dir, path)
         with open(path, 'rb') as file:
             characters = EoSDSHT.read(file) #TODO: modular
         return characters