From acb88e2f919cee9bc18e8ca462527ba0fbdf75a3 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Mon, 23 Apr 2007 06:23:27 +0000 Subject: [PATCH] Look in the application directory and in DATADIR for SMData.smzip. This way the distributed binary can be run its directory or if compiled from source, the data may be installed and we will look there instead. For development, of course, SMData.smzip should not be installed as we should be using the files in Themes and so forth. One easy way to insure that is to set the prefix somewhere like /tmp when developing so that it will look for /tmp/share/stepmania\ cvs/SMData.smzip, which will not exist. --- .../src/arch/ArchHooks/ArchHooks_Unix.cpp | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_Unix.cpp b/stepmania/src/arch/ArchHooks/ArchHooks_Unix.cpp index c866d9fc2c..59cd4969e5 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks_Unix.cpp +++ b/stepmania/src/arch/ArchHooks/ArchHooks_Unix.cpp @@ -267,11 +267,35 @@ void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable ) FILEMAN->Mount( "dir", sUserDataPath + "/Save", "/Save" ); FILEMAN->Mount( "dir", sUserDataPath + "/Screenshots", "/Screenshots" ); - /* Search for a directory with "Songs" in it. Be careful: the CWD is likely to - * be ~, and it's possible that some users will have a ~/Songs/ directory that - * has nothing to do with us, so check the initial directory last. */ + /* Search for SMData.smzip in the directory of the executable + * first in case some one has an older version installed in + * the datadir. Then search the datadir. Lastly look for + * Songs, using cwd last. + * XXX: Songs seems like a bad choice. The game will still run + * without Songs and they might have AdditionalSongFolders + * pointing to their songs. Themes seems like the one to look + * for since the game will not run without that. */ RString Root = ""; struct stat st; + if( !access(sDirOfExecutable + "/SMData.smzip", R_OK) ) + { + FILEMAN->Mount( "dir", sDirOfExecutable, "/" ); + FILEMAN->Mount( "zip", "/SMData.smzip", "/" ); + return; + } +#ifdef DATADIR +#define XSTR(x) #x +#define STR(x) XSTR(x) + RString datadir = XSTR(DATADIR) "/" + sProductId; + if( !access(datadir + "/SMData.smzip", R_OK) ) + { + FILEMAN->Mount( "dir", datadir, "/" ); + FILEMAN->Mount( "zip", "/SMData.smzip", "/" ); + return; + } +#undef STR +#undef XSTR +#endif if( Root == "" && !stat( sDirOfExecutable + "/Songs", &st ) && st.st_mode&S_IFDIR ) Root = sDirOfExecutable; if( Root == "" && !stat( RageFileManagerUtil::sInitialWorkingDirectory + "/Songs", &st ) && st.st_mode&S_IFDIR )