issue #1687: Updating the comments for CCFileUtils.

This commit is contained in:
James Chen 2013-02-01 16:46:15 +08:00
parent a110778739
commit 357da4f2fc
2 changed files with 14 additions and 13 deletions

View File

@ -333,18 +333,10 @@ NS_CC_BEGIN
#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;
void CCFileUtils::purgeFileUtils()
{
if (s_sharedFileUtils != NULL)
{
s_sharedFileUtils->purgeCachedEntries();
CC_SAFE_RELEASE(s_sharedFileUtils->m_pFilenameLookupDict);
}
CC_SAFE_DELETE(s_sharedFileUtils);
}
@ -355,7 +347,7 @@ CCFileUtils::CCFileUtils()
CCFileUtils::~CCFileUtils()
{
CC_SAFE_RELEASE(m_pFilenameLookupDict);
}
bool CCFileUtils::init()
@ -367,7 +359,7 @@ bool CCFileUtils::init()
void CCFileUtils::purgeCachedEntries()
{
s_fullPathCache.clear();
m_fullPathCache.clear();
}
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 ?
std::map<std::string, std::string>::iterator cacheIter = s_fullPathCache.find(pszFileName);
if (cacheIter != s_fullPathCache.end())
std::map<std::string, std::string>::iterator cacheIter = m_fullPathCache.find(pszFileName);
if (cacheIter != m_fullPathCache.end())
{
//CCLOG("Return full path from cache: %s", cacheIter->second.c_str());
return cacheIter->second;
@ -526,7 +518,7 @@ std::string CCFileUtils::fullPathForFilename(const char* pszFileName)
if (fullpath.length() > 0)
{
// 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());
return fullpath;
}

View File

@ -26,6 +26,7 @@ THE SOFTWARE.
#include <string>
#include <vector>
#include <map>
#include "CCPlatformMacros.h"
#include "ccTypes.h"
#include "ccTypeInfo.h"
@ -258,6 +259,8 @@ public:
/**
* 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.
*/
@ -342,10 +345,16 @@ protected:
*/
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.
*/
static CCFileUtils* s_sharedFileUtils;
};
// end of platform group