Index: X:/LdaFwApps/CrossWire/sword/src/mgr/swmgr.cpp =================================================================== --- X:/LdaFwApps/CrossWire/sword/src/mgr/swmgr.cpp (revision 1894) +++ X:/LdaFwApps/CrossWire/sword/src/mgr/swmgr.cpp (working copy) @@ -344,38 +344,89 @@ } +/* + * If an app is installed in [BaseCrossWireDir]/SwordApiBasedApp/SwordApiBasedApp.exe + * then the order of resolving which resources to use: + * 1. [BaseCrossWireDir]/mods.conf + * 2. [BaseCrossWireDir]/resources/mods.conf + * 3. [BaseCrossWireDir]/SwordApiBasedApp/mods.conf + * 4. [BaseCrossWireDir]/mods.d + * 5. [BaseCrossWireDir]/resources/mods.d + * 6. [BaseCrossWireDir]/SwordApiBasedApp/mods.d + * 7. [SWORD_PATH environment variable]/mods.conf + * 8. [SWORD_PATH environment variable]/mods.d + * 9. [HOME environment variable]/mods.conf + * 10.[HOME environment variable]/mods.d + * + * Caveats: - I'm not familiar with Linux ... above assumes Windows + * - Not familiar with how "augPaths" works + */ + void SWMgr::findConfig(char *configType, char **prefixPath, char **configPath, std::list *augPaths) { - SWBuf path; - ConfigEntMap::iterator entry; - ConfigEntMap::iterator lastEntry; + SWBuf path; + ConfigEntMap::iterator entry; + ConfigEntMap::iterator lastEntry; - char *envsworddir = getenv ("SWORD_PATH"); - char *envhomedir = getenv ("HOME"); + char *envsworddir = getenv ("SWORD_PATH"); + char *envhomedir = getenv ("HOME"); - *configType = 0; - //debug=1; + *configType = 0; + //debug=1; - // check working directory - DEBUGSTR("Checking working directory for mods.conf..."); + // check parent directory + DEBUGSTR("Checking parent directory for mods.conf..."); + if (FileMgr::existsFile("..", "mods.conf")) { + DEBUGSTR("found\n"); + stdstr(prefixPath, "../"); + stdstr(configPath, "../mods.conf"); + return; + } - if (FileMgr::existsFile(".", "mods.conf")) { - DEBUGSTR("found\n"); - stdstr(prefixPath, "./"); - stdstr(configPath, "./mods.conf"); - return; - } + DEBUGSTR("\nChecking sibling directory for resources/mods.conf..."); + if (FileMgr::existsFile("../resources", "mods.conf")) { + DEBUGSTR("found\n"); + stdstr(prefixPath, "../resources/"); + stdstr(configPath, "../resources/mods.conf"); + return; + } - DEBUGSTR("\nChecking working directory for mods.d..."); - if (FileMgr::existsDir(".", "mods.d")) { - DEBUGSTR("found\n"); - stdstr(prefixPath, "./"); - stdstr(configPath, "./mods.d"); - *configType = 1; - return; - } + // check working directory + DEBUGSTR("\nChecking working directory for mods.conf..."); + if (FileMgr::existsFile(".", "mods.conf")) { + DEBUGSTR("found\n"); + stdstr(prefixPath, "./"); + stdstr(configPath, "./mods.conf"); + return; + } + DEBUGSTR("\nChecking parent directory for mods.d..."); + if (FileMgr::existsDir("..", "mods.d")) { + DEBUGSTR("found\n"); + stdstr(prefixPath, "../"); + stdstr(configPath, "../mods.d"); + *configType = 1; + return; + } - // check environment variable SWORD_PATH + DEBUGSTR("\nChecking sibling directory for resources/mods.d..."); + if (FileMgr::existsDir("../resources", "mods.d")) { + DEBUGSTR("found\n"); + stdstr(prefixPath, "../resources/"); + stdstr(configPath, "../resources/mods.d"); + *configType = 1; + return; + } + + DEBUGSTR("\nChecking working directory for mods.d..."); + if (FileMgr::existsDir(".", "mods.d")) { + DEBUGSTR("found\n"); + stdstr(prefixPath, "./"); + stdstr(configPath, "./mods.d"); + *configType = 1; + return; + } + + // check environment variable SWORD_PATH DEBUGSTR("\nChecking SWORD_PATH..."); if (envsworddir != NULL) {