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::transform(lowerCasePath.begin(), lowerCasePath.end(), lowerCasePath.begin(), ::tolower);
|
||||
if ( lowerCasePath.find(".ttf") != std::string::npos ) {
|
||||
fontPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fontPath.c_str());
|
||||
|
||||
FILE *f = fopen(fontPath.c_str(), "r");
|
||||
if ( f ) {
|
||||
fclose(f);
|
||||
fontPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fontPath);
|
||||
auto* fileStream = cocos2d::FileUtils::getInstance()->openFileStream(fontPath, FileStream::Mode::READ);
|
||||
if ( fileStream ) {
|
||||
delete fileStream;
|
||||
fontCache.insert(std::pair<std::string, std::string>(family_name, fontPath));
|
||||
return fontPath;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue