mirror of https://github.com/axmolengine/axmol.git
issue #1687: Updating the comments for CCFileUtils.
This commit is contained in:
parent
a110778739
commit
357da4f2fc
|
@ -333,18 +333,10 @@ NS_CC_BEGIN
|
||||||
#endif /* (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) && (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) */
|
#endif /* (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) && (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) */
|
||||||
|
|
||||||
|
|
||||||
static std::map<std::string, std::string> s_fullPathCache;
|
|
||||||
|
|
||||||
CCFileUtils* CCFileUtils::s_sharedFileUtils = NULL;
|
CCFileUtils* CCFileUtils::s_sharedFileUtils = NULL;
|
||||||
|
|
||||||
void CCFileUtils::purgeFileUtils()
|
void CCFileUtils::purgeFileUtils()
|
||||||
{
|
{
|
||||||
if (s_sharedFileUtils != NULL)
|
|
||||||
{
|
|
||||||
s_sharedFileUtils->purgeCachedEntries();
|
|
||||||
CC_SAFE_RELEASE(s_sharedFileUtils->m_pFilenameLookupDict);
|
|
||||||
}
|
|
||||||
|
|
||||||
CC_SAFE_DELETE(s_sharedFileUtils);
|
CC_SAFE_DELETE(s_sharedFileUtils);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,7 +347,7 @@ CCFileUtils::CCFileUtils()
|
||||||
|
|
||||||
CCFileUtils::~CCFileUtils()
|
CCFileUtils::~CCFileUtils()
|
||||||
{
|
{
|
||||||
|
CC_SAFE_RELEASE(m_pFilenameLookupDict);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCFileUtils::init()
|
bool CCFileUtils::init()
|
||||||
|
@ -367,7 +359,7 @@ bool CCFileUtils::init()
|
||||||
|
|
||||||
void CCFileUtils::purgeCachedEntries()
|
void CCFileUtils::purgeCachedEntries()
|
||||||
{
|
{
|
||||||
s_fullPathCache.clear();
|
m_fullPathCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize)
|
unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize)
|
||||||
|
@ -502,8 +494,8 @@ std::string CCFileUtils::fullPathForFilename(const char* pszFileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Already Cached ?
|
// Already Cached ?
|
||||||
std::map<std::string, std::string>::iterator cacheIter = s_fullPathCache.find(pszFileName);
|
std::map<std::string, std::string>::iterator cacheIter = m_fullPathCache.find(pszFileName);
|
||||||
if (cacheIter != s_fullPathCache.end())
|
if (cacheIter != m_fullPathCache.end())
|
||||||
{
|
{
|
||||||
//CCLOG("Return full path from cache: %s", cacheIter->second.c_str());
|
//CCLOG("Return full path from cache: %s", cacheIter->second.c_str());
|
||||||
return cacheIter->second;
|
return cacheIter->second;
|
||||||
|
@ -526,7 +518,7 @@ std::string CCFileUtils::fullPathForFilename(const char* pszFileName)
|
||||||
if (fullpath.length() > 0)
|
if (fullpath.length() > 0)
|
||||||
{
|
{
|
||||||
// Using the filename passed in as key.
|
// Using the filename passed in as key.
|
||||||
s_fullPathCache.insert(std::pair<std::string, std::string>(pszFileName, fullpath));
|
m_fullPathCache.insert(std::pair<std::string, std::string>(pszFileName, fullpath));
|
||||||
//CCLOG("Returning path: %s", fullpath.c_str());
|
//CCLOG("Returning path: %s", fullpath.c_str());
|
||||||
return fullpath;
|
return fullpath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
#include "CCPlatformMacros.h"
|
#include "CCPlatformMacros.h"
|
||||||
#include "ccTypes.h"
|
#include "ccTypes.h"
|
||||||
#include "ccTypeInfo.h"
|
#include "ccTypeInfo.h"
|
||||||
|
@ -258,6 +259,8 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the path is an absolute path.
|
* Checks whether the path is an absolute path.
|
||||||
|
* @note On Android, if the parameter passed in is relative to "assets/", this method will treat it as an absolute path.
|
||||||
|
* Also on Blackberry, path starts with "app/native/Resources/" is treated as an absolute path.
|
||||||
*
|
*
|
||||||
* @param strPath The path that needs to be checked.
|
* @param strPath The path that needs to be checked.
|
||||||
*/
|
*/
|
||||||
|
@ -342,10 +345,16 @@ protected:
|
||||||
*/
|
*/
|
||||||
std::string m_strDefaultResRootPath;
|
std::string m_strDefaultResRootPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The full path cache. When files are found, it will be added into this cache. It could improve the performance of file search.
|
||||||
|
*/
|
||||||
|
std::map<std::string, std::string> m_fullPathCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The singleton pointer of CCFileUtils.
|
* The singleton pointer of CCFileUtils.
|
||||||
*/
|
*/
|
||||||
static CCFileUtils* s_sharedFileUtils;
|
static CCFileUtils* s_sharedFileUtils;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of platform group
|
// end of platform group
|
||||||
|
|
Loading…
Reference in New Issue