mirror of https://github.com/axmolengine/axmol.git
Use FileStream instead of fopen to check if file can be opened in read mode
This commit is contained in:
parent
d76cb66e8e
commit
bceabe87c1
|
@ -345,11 +345,10 @@ public:
|
||||||
std::string lowerCasePath = fontPath;
|
std::string lowerCasePath = fontPath;
|
||||||
std::transform(lowerCasePath.begin(), lowerCasePath.end(), lowerCasePath.begin(), ::tolower);
|
std::transform(lowerCasePath.begin(), lowerCasePath.end(), lowerCasePath.begin(), ::tolower);
|
||||||
if ( lowerCasePath.find(".ttf") != std::string::npos ) {
|
if ( lowerCasePath.find(".ttf") != std::string::npos ) {
|
||||||
fontPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fontPath.c_str());
|
fontPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fontPath);
|
||||||
|
auto* fileStream = cocos2d::FileUtils::getInstance()->openFileStream(fontPath, FileStream::Mode::READ);
|
||||||
FILE *f = fopen(fontPath.c_str(), "r");
|
if ( fileStream ) {
|
||||||
if ( f ) {
|
delete fileStream;
|
||||||
fclose(f);
|
|
||||||
fontCache.insert(std::pair<std::string, std::string>(family_name, fontPath));
|
fontCache.insert(std::pair<std::string, std::string>(family_name, fontPath));
|
||||||
return fontPath;
|
return fontPath;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue