mirror of
https://github.com/edubart/otclient.git
synced 2025-12-18 14:47:11 +01:00
Minor changes in file type handling
This commit is contained in:
@@ -43,7 +43,7 @@ void ModuleManager::discoverModules()
|
||||
for(const std::string& moduleDir : moduleDirs) {
|
||||
auto moduleFiles = g_resources.listDirectoryFiles("/" + moduleDir);
|
||||
for(const std::string& moduleFile : moduleFiles) {
|
||||
if(stdext::ends_with(moduleFile, ".otmod")) {
|
||||
if(g_resources.isFileType(moduleFile, "otmod")) {
|
||||
ModulePtr module = discoverModule("/" + moduleDir + "/" + moduleFile);
|
||||
if(module && module->isAutoLoad())
|
||||
m_autoLoadModules.insert(std::make_pair(module->getAutoLoadPriority(), module));
|
||||
|
||||
@@ -311,9 +311,16 @@ std::string ResourceManager::getUserDir()
|
||||
return PHYSFS_getUserDir();
|
||||
}
|
||||
|
||||
std::string ResourceManager::guessFileType(const std::string& filename, const std::string& type)
|
||||
std::string ResourceManager::guessFilePath(const std::string& filename, const std::string& type)
|
||||
{
|
||||
if(g_resources.fileExists(filename))
|
||||
if(isFileType(filename, type))
|
||||
return filename;
|
||||
return filename + "." + type;
|
||||
}
|
||||
|
||||
bool ResourceManager::isFileType(const std::string& filename, const std::string& type)
|
||||
{
|
||||
if(stdext::ends_with(filename, std::string(".") + type))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,8 @@ public:
|
||||
std::string getWorkDir() { return m_workDir; }
|
||||
std::deque<std::string> getSearchPaths() { return m_searchPaths; }
|
||||
|
||||
std::string guessFileType(const std::string& filename, const std::string& type);
|
||||
std::string guessFilePath(const std::string& filename, const std::string& type);
|
||||
bool isFileType(const std::string& filename, const std::string& type);
|
||||
|
||||
private:
|
||||
std::string m_workDir;
|
||||
|
||||
Reference in New Issue
Block a user