mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-14 02:33:51 +02:00
Merge pull request #79 from ArseniyShestakov/fixIssue1557
Only remove extension if it belongs to specified file type
This commit is contained in:
commit
1396476869
@ -33,16 +33,18 @@ ResourceID::ResourceID()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResourceID::ResourceID(std::string name)
|
ResourceID::ResourceID(std::string name)
|
||||||
|
:type(EResType::UNDEFINED)
|
||||||
{
|
{
|
||||||
CFileInfo info(std::move(name));
|
CFileInfo info(std::move(name));
|
||||||
setName(info.getStem());
|
|
||||||
setType(info.getType());
|
setType(info.getType());
|
||||||
|
setName(info.getStem());
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceID::ResourceID(std::string name, EResType::Type type)
|
ResourceID::ResourceID(std::string name, EResType::Type type)
|
||||||
|
:type(EResType::UNDEFINED)
|
||||||
{
|
{
|
||||||
setName(std::move(name));
|
|
||||||
setType(type);
|
setType(type);
|
||||||
|
setName(std::move(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ResourceID::getName() const
|
std::string ResourceID::getName() const
|
||||||
@ -57,12 +59,18 @@ EResType::Type ResourceID::getType() const
|
|||||||
|
|
||||||
void ResourceID::setName(std::string name)
|
void ResourceID::setName(std::string name)
|
||||||
{
|
{
|
||||||
|
// setName shouldn't be used if type is UNDEFINED
|
||||||
|
assert(type != EResType::UNDEFINED);
|
||||||
|
|
||||||
this->name = std::move(name);
|
this->name = std::move(name);
|
||||||
|
|
||||||
size_t dotPos = this->name.find_last_of("/.");
|
size_t dotPos = this->name.find_last_of("/.");
|
||||||
|
|
||||||
if(dotPos != std::string::npos && this->name[dotPos] == '.')
|
if(dotPos != std::string::npos && this->name[dotPos] == '.'
|
||||||
|
&& this->type == EResTypeHelper::getTypeFromExtension(this->name.substr(dotPos)))
|
||||||
|
{
|
||||||
this->name.erase(dotPos);
|
this->name.erase(dotPos);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_TRIVIAL_TOUPPER
|
#ifdef ENABLE_TRIVIAL_TOUPPER
|
||||||
toUpper(this->name);
|
toUpper(this->name);
|
||||||
|
@ -56,7 +56,8 @@ namespace EResType
|
|||||||
ERM,
|
ERM,
|
||||||
ERT,
|
ERT,
|
||||||
ERS,
|
ERS,
|
||||||
OTHER
|
OTHER,
|
||||||
|
UNDEFINED
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user