Merge pull request #1916 from dumganhar/master

CCFileUtils::s|gSearchPath -> CCFileUtils::s|gSearchPaths.
This commit is contained in:
James Chen 2013-01-28 18:02:16 -08:00
commit db61976a71
27 changed files with 64 additions and 63 deletions

View File

@ -177,7 +177,7 @@ public:
/**
@brief Set the resource directory; we will find resources relative to this directory.
@param pszDirectoryName Relative path to root.
@deprecated Please use setSearchPath instead.
@deprecated Please use setSearchPaths instead.
*/
CC_DEPRECATED_ATTRIBUTE void setResourceDirectory(const char *pszDirectoryName);
@ -206,17 +206,17 @@ public:
* @param searchPaths
* @since v2.1
*/
void setSearchPath(const std::vector<std::string>& searchPaths);
void setSearchPaths(const std::vector<std::string>& searchPaths);
/**
* Gets the array of search paths.
*
*/
const std::vector<std::string>& getSearchPath();
const std::vector<std::string>& getSearchPaths();
/**
* Gets the resource directory
* @deprecated Please use getSearchPath() instead.
* @deprecated Please use getSearchPaths() instead.
*/
CC_DEPRECATED_ATTRIBUTE const char* getResourceDirectory();

View File

@ -410,7 +410,7 @@ const std::vector<std::string>& CCFileUtils::getSearchResolutionsOrder()
return m_searchResolutionsOrderArray;
}
const std::vector<std::string>& CCFileUtils::getSearchPath()
const std::vector<std::string>& CCFileUtils::getSearchPaths()
{
return m_searchPathArray;
}

View File

@ -92,7 +92,7 @@ std::string CCFileUtils::fullPathForFilename(const char* pszFileName)
// 2) Files not in APK, e.g. /data/data/org.cocos2dx.hellocpp/cache/path/path/file.png, or /sdcard/path/path/file.png.
// So these two situations need to be checked on Android.
std::string strFileName = pszFileName;
if (pszFileName[0] == '/' || strFileName.find("assets/") == 0)
if (pszFileName[0] == '/' || strFileName.find(m_strDefaultResRootPath) == 0)
{
CCLOG("Return absolute path( %s ) directly.", pszFileName);
return pszFileName;
@ -241,12 +241,12 @@ void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory)
{
if (pszResourceDirectory == NULL) return;
m_obDirectory = pszResourceDirectory;
std::vector<std::string> searchPaths = this->getSearchPath();;
std::vector<std::string> searchPaths = this->getSearchPaths();;
searchPaths.insert(searchPaths.begin(), pszResourceDirectory);
this->setSearchPath(searchPaths);
this->setSearchPaths(searchPaths);
}
void CCFileUtils::setSearchPath(const std::vector<std::string>& searchPaths)
void CCFileUtils::setSearchPaths(const std::vector<std::string>& searchPaths)
{
bool bExistDefaultRootPath = false;

View File

@ -88,9 +88,9 @@ void CCApplication::setResourceRootPath(const std::string& rootResDir)
m_resourceRootPath += '/';
}
CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
std::vector<std::string> searchPaths = pFileUtils->getSearchPath();
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
searchPaths.insert(searchPaths.begin(), m_resourceRootPath);
pFileUtils->setSearchPath(searchPaths);
pFileUtils->setSearchPaths(searchPaths);
}
const std::string& CCApplication::getResourceRootPath(void)

View File

@ -65,13 +65,13 @@ public:
/**
* Sets the Resource root path.
* @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPath() instead.
* @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPaths() instead.
*/
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir);
/**
* Gets the Resource root path.
* @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPath() instead.
* @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPaths() instead.
*/
CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void);

View File

@ -104,8 +104,9 @@ std::string CCFileUtils::fullPathForFilename(const char* pszFileName)
CCAssert(pszFileName != NULL, "CCFileUtils: Invalid path");
// Return directly if it's absolute path.
if (pszFileName[0] == '/')
if (pszFileName[0] == '/' || strFileName.find(m_strDefaultResRootPath) == 0)
{
CCLOG("Return absolute path( %s ) directly.", pszFileName);
return pszFileName;
}
@ -204,12 +205,12 @@ void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory)
{
if (pszResourceDirectory == NULL) return;
m_obDirectory = pszResourceDirectory;
std::vector<std::string> searchPaths = this->getSearchPath();;
std::vector<std::string> searchPaths = this->getSearchPaths();;
searchPaths.insert(searchPaths.begin(), pszResourceDirectory);
this->setSearchPath(searchPaths);
this->setSearchPaths(searchPaths);
}
void CCFileUtils::setSearchPath(const std::vector<std::string>& searchPaths)
void CCFileUtils::setSearchPaths(const std::vector<std::string>& searchPaths)
{
bool bExistDefaultRootPath = false;

View File

@ -205,7 +205,7 @@ const std::vector<std::string>& CCFileUtils::getSearchResolutionsOrder()
return m_searchResolutionsOrderArray;
}
void CCFileUtils::setSearchPath(const std::vector<std::string>& searchPaths)
void CCFileUtils::setSearchPaths(const std::vector<std::string>& searchPaths)
{
bool bExistDefault = false;
m_searchPathArray.clear();
@ -223,7 +223,7 @@ void CCFileUtils::setSearchPath(const std::vector<std::string>& searchPaths)
}
}
const std::vector<std::string>& CCFileUtils::getSearchPath()
const std::vector<std::string>& CCFileUtils::getSearchPaths()
{
return m_searchPathArray;
}

View File

@ -74,9 +74,9 @@ void CCApplication::setResourceRootPath(const std::string& rootResDir)
m_resourceRootPath += '/';
}
CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
std::vector<std::string> searchPaths = pFileUtils->getSearchPath();
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
searchPaths.insert(searchPaths.begin(), m_resourceRootPath);
pFileUtils->setSearchPath(searchPaths);
pFileUtils->setSearchPaths(searchPaths);
}
const std::string& CCApplication::getResourceRootPath(void)

View File

@ -43,13 +43,13 @@ public:
/**
* Sets the Resource root path.
* @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPath() instead.
* @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPaths() instead.
*/
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir);
/**
* Gets the Resource root path.
* @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPath() instead.
* @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPaths() instead.
*/
CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void);

View File

@ -199,12 +199,12 @@ void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory)
{
if (pszResourceDirectory == NULL) return;
m_obDirectory = pszResourceDirectory;
std::vector<std::string> searchPaths = this->getSearchPath();;
std::vector<std::string> searchPaths = this->getSearchPaths();;
searchPaths.insert(searchPaths.begin(), pszResourceDirectory);
this->setSearchPath(searchPaths);
this->setSearchPaths(searchPaths);
}
void CCFileUtils::setSearchPath(const std::vector<std::string>& searchPaths)
void CCFileUtils::setSearchPaths(const std::vector<std::string>& searchPaths)
{
bool bExistDefaultRootPath = false;

View File

@ -71,13 +71,13 @@ public:
/**
* Sets the Resource root path.
* @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPath() instead.
* @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPaths() instead.
*/
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir);
/**
* Gets the Resource root path.
* @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPath() instead.
* @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPaths() instead.
*/
CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void);

View File

@ -131,9 +131,9 @@ void CCApplication::setResourceRootPath(const std::string& rootResDir)
m_resourceRootPath += '/';
}
CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
std::vector<std::string> searchPaths = pFileUtils->getSearchPath();
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
searchPaths.insert(searchPaths.begin(), m_resourceRootPath);
pFileUtils->setSearchPath(searchPaths);
pFileUtils->setSearchPaths(searchPaths);
}
const std::string& CCApplication::getResourceRootPath(void)

View File

@ -207,7 +207,7 @@ const std::vector<std::string>& CCFileUtils::getSearchResolutionsOrder()
return m_searchResolutionsOrderArray;
}
void CCFileUtils::setSearchPath(const std::vector<std::string>& searchPaths)
void CCFileUtils::setSearchPaths(const std::vector<std::string>& searchPaths)
{
bool bExistDefault = false;
m_searchPathArray.clear();
@ -225,7 +225,7 @@ void CCFileUtils::setSearchPath(const std::vector<std::string>& searchPaths)
}
}
const std::vector<std::string>& CCFileUtils::getSearchPath()
const std::vector<std::string>& CCFileUtils::getSearchPaths()
{
return m_searchPathArray;
}

View File

@ -196,12 +196,12 @@ void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory)
{
if (pszResourceDirectory == NULL) return;
m_obDirectory = pszResourceDirectory;
std::vector<std::string> searchPaths = this->getSearchPath();;
std::vector<std::string> searchPaths = this->getSearchPaths();;
searchPaths.insert(searchPaths.begin(), pszResourceDirectory);
this->setSearchPath(searchPaths);
this->setSearchPaths(searchPaths);
}
void CCFileUtils::setSearchPath(const std::vector<std::string>& searchPaths)
void CCFileUtils::setSearchPaths(const std::vector<std::string>& searchPaths)
{
bool bExistDefaultRootPath = false;

View File

@ -164,9 +164,9 @@ void CCApplication::setResourceRootPath(const std::string& rootResDir)
m_resourceRootPath += '/';
}
CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
std::vector<std::string> searchPaths = pFileUtils->getSearchPath();
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
searchPaths.insert(searchPaths.begin(), m_resourceRootPath);
pFileUtils->setSearchPath(searchPaths);
pFileUtils->setSearchPaths(searchPaths);
}
const std::string& CCApplication::getResourceRootPath(void)

View File

@ -38,13 +38,13 @@ public:
/**
* Sets the Resource root path.
* @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPath() instead.
* @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPaths() instead.
*/
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir);
/**
* Gets the Resource root path.
* @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPath() instead.
* @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPaths() instead.
*/
CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void);

View File

@ -210,12 +210,12 @@ void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory)
{
if (pszResourceDirectory == NULL) return;
m_obDirectory = pszResourceDirectory;
std::vector<std::string> searchPaths = this->getSearchPath();;
std::vector<std::string> searchPaths = this->getSearchPaths();;
searchPaths.insert(searchPaths.begin(), pszResourceDirectory);
this->setSearchPath(searchPaths);
this->setSearchPaths(searchPaths);
}
void CCFileUtils::setSearchPath(const std::vector<std::string>& searchPaths)
void CCFileUtils::setSearchPaths(const std::vector<std::string>& searchPaths)
{
bool bExistDefaultRootPath = false;

View File

@ -59,7 +59,7 @@ bool AppDelegate::applicationDidFinishLaunching() {
}
// set searching path
CCFileUtils::sharedFileUtils()->setSearchPath(searchPath);
CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);
// turn on display FPS
pDirector->setDisplayStats(true);

View File

@ -32,7 +32,7 @@ bool AppDelegate::applicationDidFinishLaunching()
CCSize resourceSize = CCSizeMake(960, 640);
std::vector<std::string> searchPaths;
searchPaths.push_back("hd");
pFileUtils->setSearchPath(searchPaths);
pFileUtils->setSearchPaths(searchPaths);
pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
}

View File

@ -138,10 +138,10 @@ void TestResolutionDirectories::onEnter()
string ret;
sharedFileUtils->purgeCachedEntries();
m_defaultSearchPathArray = sharedFileUtils->getSearchPath();
m_defaultSearchPathArray = sharedFileUtils->getSearchPaths();
vector<string> searchPaths = m_defaultSearchPathArray;
searchPaths.insert(searchPaths.begin(), "Misc");
sharedFileUtils->setSearchPath(searchPaths);
sharedFileUtils->setSearchPaths(searchPaths);
m_defaultResolutionsOrderArray = sharedFileUtils->getSearchResolutionsOrder();
vector<string> resolutionsOrder = m_defaultResolutionsOrderArray;
@ -167,7 +167,7 @@ void TestResolutionDirectories::onExit()
CCFileUtils *sharedFileUtils = CCFileUtils::sharedFileUtils();
// reset search path
sharedFileUtils->setSearchPath(m_defaultSearchPathArray);
sharedFileUtils->setSearchPaths(m_defaultSearchPathArray);
sharedFileUtils->setSearchResolutionsOrder(m_defaultResolutionsOrderArray);
FileUtilsDemo::onExit();
}
@ -192,7 +192,7 @@ void TestSearchPath::onEnter()
string ret;
sharedFileUtils->purgeCachedEntries();
m_defaultSearchPathArray = sharedFileUtils->getSearchPath();
m_defaultSearchPathArray = sharedFileUtils->getSearchPaths();
vector<string> searchPaths = m_defaultSearchPathArray;
string writablePath = sharedFileUtils->getWriteablePath();
string fileName = writablePath+"external.txt";
@ -208,7 +208,7 @@ void TestSearchPath::onEnter()
searchPaths.insert(searchPaths.begin(), writablePath);
searchPaths.insert(searchPaths.begin()+1, "Misc/searchpath1");
searchPaths.insert(searchPaths.begin()+2, "Misc/searchpath2");
sharedFileUtils->setSearchPath(searchPaths);
sharedFileUtils->setSearchPaths(searchPaths);
m_defaultResolutionsOrderArray = sharedFileUtils->getSearchResolutionsOrder();
vector<string> resolutionsOrder = m_defaultResolutionsOrderArray;
@ -242,7 +242,7 @@ void TestSearchPath::onExit()
CCFileUtils *sharedFileUtils = CCFileUtils::sharedFileUtils();
// reset search path
sharedFileUtils->setSearchPath(m_defaultSearchPathArray);
sharedFileUtils->setSearchPaths(m_defaultSearchPathArray);
sharedFileUtils->setSearchResolutionsOrder(m_defaultResolutionsOrderArray);
FileUtilsDemo::onExit();
}

View File

@ -56,7 +56,7 @@ bool AppDelegate::applicationDidFinishLaunching()
searchPath.push_back("resources-iphonehd");
}
CCFileUtils::sharedFileUtils()->setSearchPath(searchPath);
CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);
pDirector->setContentScaleFactor(resourceSize.height/designSize.height);

View File

@ -100,9 +100,9 @@ bool AppDelegate::applicationDidFinishLaunching()
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);
std::vector<std::string> searchPaths = pFileUtils->getSearchPath();
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
searchPaths.insert(searchPaths.begin(), pFileUtils->getWriteablePath());
pFileUtils->setSearchPath(searchPaths);
pFileUtils->setSearchPaths(searchPaths);
PlayerStatus::setDeviceResolution(res);
// turn on display FPS

View File

@ -41,7 +41,7 @@ bool AppDelegate::applicationDidFinishLaunching()
if (platform == kTargetIphone || platform == kTargetIpad)
{
searchPaths.push_back("Published-iOS"); // Resources/Published-iOS
CCFileUtils::sharedFileUtils()->setSearchPath(searchPaths);
CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
if (screenSize.height > 480)
{

@ -1 +1 @@
Subproject commit b744bb4009bdd74d428587ba51d991294b549be4
Subproject commit 3459984d2ff434c51be47ed51e8e24882b25a641

View File

@ -2567,7 +2567,7 @@ JSBool js_cocos2dx_CCFileUtils_setSearchResolutionsOrder(JSContext *cx, uint32_t
return JS_FALSE;
}
JSBool js_cocos2dx_CCFileUtils_setSearchPath(JSContext *cx, uint32_t argc, jsval *vp)
JSBool js_cocos2dx_CCFileUtils_setSearchPaths(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
@ -2580,14 +2580,14 @@ JSBool js_cocos2dx_CCFileUtils_setSearchPath(JSContext *cx, uint32_t argc, jsval
std::vector<std::string> arg0;
ok &= jsval_to_string_vector(cx, argv[0], arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->setSearchPath(arg0);
cobj->setSearchPaths(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_cocos2dx_CCFileUtils_getSearchPath(JSContext *cx, uint32_t argc, jsval *vp)
JSBool js_cocos2dx_CCFileUtils_getSearchPaths(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
@ -2595,7 +2595,7 @@ JSBool js_cocos2dx_CCFileUtils_getSearchPath(JSContext *cx, uint32_t argc, jsval
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
std::vector<std::string> ret = cobj->getSearchPath();
std::vector<std::string> ret = cobj->getSearchPaths();
jsval jsret;
jsret = string_vector_to_jsval(cx, ret);
JS_SET_RVAL(cx, vp, jsret);
@ -2675,8 +2675,8 @@ void register_cocos2dx_js_extensions(JSContext* cx, JSObject* global)
JS_DefineFunction(cx, js_cocos2dx_CCMenu_prototype, "alignItemsInColumns", js_cocos2dx_CCMenu_alignItemsInColumns, 1, JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_PERMANENT);
JS_DefineFunction(cx, js_cocos2dx_CCFileUtils_prototype, "setSearchResolutionsOrder", js_cocos2dx_CCFileUtils_setSearchResolutionsOrder, 1, JSPROP_PERMANENT | JSPROP_SHARED);
JS_DefineFunction(cx, js_cocos2dx_CCFileUtils_prototype, "setSearchPath", js_cocos2dx_CCFileUtils_setSearchPath, 1, JSPROP_PERMANENT | JSPROP_SHARED);
JS_DefineFunction(cx, js_cocos2dx_CCFileUtils_prototype, "getSearchPath", js_cocos2dx_CCFileUtils_getSearchPath, 0, JSPROP_PERMANENT | JSPROP_SHARED);
JS_DefineFunction(cx, js_cocos2dx_CCFileUtils_prototype, "setSearchPaths", js_cocos2dx_CCFileUtils_setSearchPaths, 1, JSPROP_PERMANENT | JSPROP_SHARED);
JS_DefineFunction(cx, js_cocos2dx_CCFileUtils_prototype, "getSearchPaths", js_cocos2dx_CCFileUtils_getSearchPaths, 0, JSPROP_PERMANENT | JSPROP_SHARED);
JS_DefineFunction(cx, js_cocos2dx_CCFileUtils_prototype, "getSearchResolutionsOrder", js_cocos2dx_CCFileUtils_getSearchResolutionsOrder, 0, JSPROP_PERMANENT | JSPROP_SHARED);

View File

@ -96,7 +96,7 @@ skip = CCNode::[.*Transform convertToWindowSpace getChildren ^setPosition$ getGr
CCTimer::[getSelector],
CC.*Loader$::[*],
*::[copyWith.* onEnter.* onExit.* description getObjectType .*RGB.* .*HSV.*],
CCFileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPath$]
CCFileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$]
rename_functions = CCDirector::[sharedDirector=getInstance],
CCSpriteFrameCache::[sharedSpriteFrameCache=getInstance addSpriteFramesWithFile=addSpriteFrames spriteFrameByName=getSpriteFrame isFlipX=isFlippedX isFlipY=isFlippedY],

View File

@ -99,7 +99,7 @@ skip = CCNode::[.*Transform convertToWindowSpace getChildren ^setPosition$ getGr
CCTimer::[getSelector],
CC.*Loader$::[*],
*::[copyWith.* onEnter.* onExit.* description getObjectType .*RGB.* .*HSV.*],
CCFileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPath$]
CCFileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$]
rename_functions = CCDirector::[sharedDirector=getInstance],
CCSpriteFrameCache::[sharedSpriteFrameCache=getInstance addSpriteFramesWithFile=addSpriteFrames spriteFrameByName=getSpriteFrame isFlipX=isFlippedX isFlipY=isFlippedY],