mirror of https://github.com/axmolengine/axmol.git
Merge pull request #1243 from dumganhar/gles20
Resource file searching implementation for blackberry port.
This commit is contained in:
commit
6681cf74ef
|
@ -1,5 +1,5 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010 cocos2d-x.org
|
||||
Copyright (c) 2012 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
@ -25,6 +25,7 @@ THE SOFTWARE.
|
|||
#define __CC_PLATFORM_FILEUTILS_CPP__
|
||||
#include "platform/CCFileUtilsCommon_cpp.h"
|
||||
#include "CCApplication.h"
|
||||
#include <unistd.h>
|
||||
|
||||
NS_CC_BEGIN;
|
||||
|
||||
|
@ -57,9 +58,12 @@ void CCFileUtils::purgeCachedEntries()
|
|||
|
||||
static std::string fullPathFromRelativePathThreadSafe(const char* pszRelativePath)
|
||||
{
|
||||
bool bFileExist = true;
|
||||
std::string ret("");
|
||||
std::string strPathWithoutResDir("");
|
||||
const char* pszRootPath = CCApplication::sharedApplication()->getResourceRootPath();
|
||||
CCAssert(pszRootPath != NULL, "The resource root path must be set in the main.cpp");
|
||||
CCAssert(pszRelativePath != NULL, "Parameter can't be NULL!");
|
||||
|
||||
std::string pstrRelativePath = pszRelativePath;
|
||||
// if the relative path contains root path, skip it.
|
||||
|
@ -68,6 +72,8 @@ static std::string fullPathFromRelativePathThreadSafe(const char* pszRelativePat
|
|||
ret += pszRootPath;
|
||||
}
|
||||
|
||||
strPathWithoutResDir = ret + pszRelativePath;
|
||||
|
||||
const char* resDir = CCFileUtils::sharedFileUtils()->getResourceDirectory();
|
||||
|
||||
if (resDir != NULL)
|
||||
|
@ -81,10 +87,35 @@ static std::string fullPathFromRelativePathThreadSafe(const char* pszRelativePat
|
|||
}
|
||||
}
|
||||
|
||||
if (pszRelativePath != NULL)
|
||||
ret += pszRelativePath;
|
||||
|
||||
// If file or directory doesn't exist, try to find it in the root path.
|
||||
if (access(ret.c_str(), F_OK) == -1)
|
||||
{
|
||||
ret += pszRelativePath;
|
||||
//CCLOG("file or directory(%s) in Resource Directory doesn't exist.", ret.c_str());
|
||||
ret = strPathWithoutResDir;
|
||||
|
||||
if (access(ret.c_str(), F_OK) == -1)
|
||||
{
|
||||
//CCLOG("file or directory(%s) in Root Directory also doesn't exist.", ret.c_str());
|
||||
bFileExist = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//CCLOG("(%s) in Root Directory exist.", ret.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//CCLOG("(%s) in Resource Directory exist.", ret.c_str());
|
||||
}
|
||||
|
||||
if (!bFileExist)
|
||||
{ // Can't find the file, return the relative path.
|
||||
ret = pszRelativePath;
|
||||
//CCLOG("Can't find the file, return the relative path(%s).", ret.c_str());
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ void CCFileUtils::purgeCachedEntries()
|
|||
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
|
||||
{
|
||||
bool bFileExist = true;
|
||||
const char* resDir = CCFileUtils::sharedFileUtils()->getResourceDirectory();
|
||||
const char* resDir = m_obDirectory.c_str();
|
||||
CCString* pRet = CCString::create("");
|
||||
|
||||
if ((strlen(pszRelativePath) > 1 && pszRelativePath[1] == ':'))
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
</option>
|
||||
<option id="com.qnx.qcc.option.linker.security.1794064552" name="Enhanced Security (-Wl,-z,relro -Wl,-z,now)" superClass="com.qnx.qcc.option.linker.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraryPaths.1757627798" name="Library Paths (-L)" superClass="com.qnx.qcc.option.linker.libraryPaths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/cocos2dx/Device-Release}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/cocos2dx/Device-Debug}""/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/lib"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/usr/lib"/>
|
||||
<listOptionValue builtIn="false" value="../../../../cocos2dx/proj.blackberry/${ConfigName}"/>
|
||||
|
@ -97,7 +97,7 @@
|
|||
<externalSettings containerId="cocos2dx;" factoryId="org.eclipse.cdt.core.cfg.export.settings.sipplier">
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/cocos2dx"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/cocos2dx/Device-Release"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/cocos2dx/Device-Debug"/>
|
||||
<entry flags="RESOLVED" kind="libraryFile" name="cocos2dx"/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<!-- A universally unique application identifier. Must be unique across all BlackBerry Tablet OS applications.
|
||||
Using a reverse DNS-style name as the id is recommended. (Eg. com.example.ExampleApplication.) Required. -->
|
||||
<id>com.example.HelloCpp</id>
|
||||
<id>org.cocos2dx.HelloCpp</id>
|
||||
|
||||
<!-- The name that is displayed in the BlackBerry Tablet OS application installer.
|
||||
May have multiple values for each language. See samples or xsd schema file. Optional. -->
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
</option>
|
||||
<option id="com.qnx.qcc.option.linker.security.1794064552" name="Enhanced Security (-Wl,-z,relro -Wl,-z,now)" superClass="com.qnx.qcc.option.linker.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraryPaths.1757627798" name="Library Paths (-L)" superClass="com.qnx.qcc.option.linker.libraryPaths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/cocos2dx/Device-Release}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/cocos2dx/Device-Debug}""/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/lib"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/usr/lib"/>
|
||||
<listOptionValue builtIn="false" value="../../../../cocos2dx/proj.blackberry/${ConfigName}"/>
|
||||
|
@ -108,7 +108,7 @@
|
|||
<externalSettings containerId="cocos2dx;" factoryId="org.eclipse.cdt.core.cfg.export.settings.sipplier">
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/cocos2dx"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/cocos2dx/Device-Release"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/cocos2dx/Device-Debug"/>
|
||||
<entry flags="RESOLVED" kind="libraryFile" name="cocos2dx"/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<!-- A universally unique application identifier. Must be unique across all BlackBerry Tablet OS applications.
|
||||
Using a reverse DNS-style name as the id is recommended. (Eg. com.example.ExampleApplication.) Required. -->
|
||||
<id>com.example.HelloLua</id>
|
||||
<id>org.cocos2dx.HelloLua</id>
|
||||
|
||||
<!-- The name that is displayed in the BlackBerry Tablet OS application installer.
|
||||
May have multiple values for each language. See samples or xsd schema file. Optional. -->
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<!-- A universally unique application identifier. Must be unique across all BlackBerry Tablet OS applications.
|
||||
Using a reverse DNS-style name as the id is recommended. (Eg. com.example.ExampleApplication.) Required. -->
|
||||
<id>com.example.TestCpp</id>
|
||||
<id>org.cocos2dx.TestCpp</id>
|
||||
|
||||
<!-- The name that is displayed in the BlackBerry Tablet OS application installer.
|
||||
May have multiple values for each language. See samples or xsd schema file. Optional. -->
|
||||
|
|
Loading…
Reference in New Issue