mirror of https://github.com/axmolengine/axmol.git
Merge pull request #1911 from dumganhar/iss1683-ccfileutils
issue #1683: Updating CCFileUtils for Blackberry and Marmalade.
This commit is contained in:
commit
2e421304ca
|
@ -48,6 +48,11 @@
|
||||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
||||||
<listOptionValue builtIn="false" value="../../include"/>
|
<listOptionValue builtIn="false" value="../../include"/>
|
||||||
<listOptionValue builtIn="false" value="../../third_party/blackberry/include"/>
|
<listOptionValue builtIn="false" value="../../third_party/blackberry/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/kazmath/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/platform"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/blackberry"/>
|
||||||
</option>
|
</option>
|
||||||
<option id="com.qnx.qcc.option.compiler.qccoptions.1372558930" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
|
<option id="com.qnx.qcc.option.compiler.qccoptions.1372558930" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
|
||||||
<inputType id="com.qnx.qcc.inputType.compiler.1849571146" superClass="com.qnx.qcc.inputType.compiler"/>
|
<inputType id="com.qnx.qcc.inputType.compiler.1849571146" superClass="com.qnx.qcc.inputType.compiler"/>
|
||||||
|
@ -128,6 +133,11 @@
|
||||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
||||||
<listOptionValue builtIn="false" value="../../include"/>
|
<listOptionValue builtIn="false" value="../../include"/>
|
||||||
<listOptionValue builtIn="false" value="../../third_party/blackberry/include"/>
|
<listOptionValue builtIn="false" value="../../third_party/blackberry/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/kazmath/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/platform"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/blackberry"/>
|
||||||
</option>
|
</option>
|
||||||
<option id="com.qnx.qcc.option.compiler.qccoptions.1936049270" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
|
<option id="com.qnx.qcc.option.compiler.qccoptions.1936049270" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
|
||||||
<inputType id="com.qnx.qcc.inputType.compiler.82187465" superClass="com.qnx.qcc.inputType.compiler"/>
|
<inputType id="com.qnx.qcc.inputType.compiler.82187465" superClass="com.qnx.qcc.inputType.compiler"/>
|
||||||
|
@ -199,6 +209,11 @@
|
||||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
||||||
<listOptionValue builtIn="false" value="../../include"/>
|
<listOptionValue builtIn="false" value="../../include"/>
|
||||||
<listOptionValue builtIn="false" value="../../third_party/blackberry/include"/>
|
<listOptionValue builtIn="false" value="../../third_party/blackberry/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/kazmath/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/platform"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/blackberry"/>
|
||||||
</option>
|
</option>
|
||||||
<option id="com.qnx.qcc.option.compiler.qccoptions.584937839" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
|
<option id="com.qnx.qcc.option.compiler.qccoptions.584937839" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
|
||||||
<inputType id="com.qnx.qcc.inputType.compiler.2036659301" superClass="com.qnx.qcc.inputType.compiler"/>
|
<inputType id="com.qnx.qcc.inputType.compiler.2036659301" superClass="com.qnx.qcc.inputType.compiler"/>
|
||||||
|
@ -273,6 +288,11 @@
|
||||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
||||||
<listOptionValue builtIn="false" value="../../include"/>
|
<listOptionValue builtIn="false" value="../../include"/>
|
||||||
<listOptionValue builtIn="false" value="../../third_party/blackberry/include"/>
|
<listOptionValue builtIn="false" value="../../third_party/blackberry/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/kazmath/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/platform"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/blackberry"/>
|
||||||
</option>
|
</option>
|
||||||
<option id="com.qnx.qcc.option.compiler.qccoptions.1106404059" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
|
<option id="com.qnx.qcc.option.compiler.qccoptions.1106404059" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
|
||||||
<inputType id="com.qnx.qcc.inputType.compiler.1381169559" superClass="com.qnx.qcc.inputType.compiler"/>
|
<inputType id="com.qnx.qcc.inputType.compiler.1381169559" superClass="com.qnx.qcc.inputType.compiler"/>
|
||||||
|
@ -283,7 +303,7 @@
|
||||||
</tool>
|
</tool>
|
||||||
<tool id="com.qnx.qcc.tool.linker.533573966" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
|
<tool id="com.qnx.qcc.tool.linker.533573966" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
|
||||||
<option id="com.qnx.qcc.option.linker.debug.1616435546" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
|
<option id="com.qnx.qcc.option.linker.debug.1616435546" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
|
||||||
<option id="com.qnx.qcc.option.linker.coverage.609660025" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
|
<option id="com.qnx.qcc.option.linker.coverage.609660025" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs -p)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
|
||||||
<option id="com.qnx.qcc.option.linker.shared.196470993" name="Shared (-shared)" superClass="com.qnx.qcc.option.linker.shared" value="true" valueType="boolean"/>
|
<option id="com.qnx.qcc.option.linker.shared.196470993" name="Shared (-shared)" superClass="com.qnx.qcc.option.linker.shared" value="true" valueType="boolean"/>
|
||||||
<option id="com.qnx.qcc.option.linker.langcpp.2037217861" name="C++ (-lang-c++)" superClass="com.qnx.qcc.option.linker.langcpp" value="true" valueType="boolean"/>
|
<option id="com.qnx.qcc.option.linker.langcpp.2037217861" name="C++ (-lang-c++)" superClass="com.qnx.qcc.option.linker.langcpp" value="true" valueType="boolean"/>
|
||||||
<option id="com.qnx.qcc.option.linker.security.1123898612" 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.security.1123898612" name="Enhanced Security (-Wl,-z,relro -Wl,-z,now)" superClass="com.qnx.qcc.option.linker.security" value="true" valueType="boolean"/>
|
||||||
|
@ -345,6 +365,11 @@
|
||||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
||||||
<listOptionValue builtIn="false" value="../../include"/>
|
<listOptionValue builtIn="false" value="../../include"/>
|
||||||
<listOptionValue builtIn="false" value="../../third_party/blackberry/include"/>
|
<listOptionValue builtIn="false" value="../../third_party/blackberry/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/kazmath/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/platform"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/blackberry"/>
|
||||||
</option>
|
</option>
|
||||||
<option id="com.qnx.qcc.option.compiler.qccoptions.641179327" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
|
<option id="com.qnx.qcc.option.compiler.qccoptions.641179327" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
|
||||||
<inputType id="com.qnx.qcc.inputType.compiler.1896937509" superClass="com.qnx.qcc.inputType.compiler"/>
|
<inputType id="com.qnx.qcc.inputType.compiler.1896937509" superClass="com.qnx.qcc.inputType.compiler"/>
|
||||||
|
@ -417,6 +442,11 @@
|
||||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
||||||
<listOptionValue builtIn="false" value="../../include"/>
|
<listOptionValue builtIn="false" value="../../include"/>
|
||||||
<listOptionValue builtIn="false" value="../../third_party/blackberry/include"/>
|
<listOptionValue builtIn="false" value="../../third_party/blackberry/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/kazmath/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/platform"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/blackberry"/>
|
||||||
</option>
|
</option>
|
||||||
<option id="com.qnx.qcc.option.compiler.qccoptions.151407782" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
|
<option id="com.qnx.qcc.option.compiler.qccoptions.151407782" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
|
||||||
<inputType id="com.qnx.qcc.inputType.compiler.746859765" superClass="com.qnx.qcc.inputType.compiler"/>
|
<inputType id="com.qnx.qcc.inputType.compiler.746859765" superClass="com.qnx.qcc.inputType.compiler"/>
|
||||||
|
@ -490,6 +520,11 @@
|
||||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
||||||
<listOptionValue builtIn="false" value="../../include"/>
|
<listOptionValue builtIn="false" value="../../include"/>
|
||||||
<listOptionValue builtIn="false" value="../../third_party/blackberry/include"/>
|
<listOptionValue builtIn="false" value="../../third_party/blackberry/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/kazmath/include"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/platform"/>
|
||||||
|
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/blackberry"/>
|
||||||
</option>
|
</option>
|
||||||
<option id="com.qnx.qcc.option.compiler.qccoptions.1555108705" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
|
<option id="com.qnx.qcc.option.compiler.qccoptions.1555108705" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions"/>
|
||||||
<inputType id="com.qnx.qcc.inputType.compiler.1894319763" superClass="com.qnx.qcc.inputType.compiler"/>
|
<inputType id="com.qnx.qcc.inputType.compiler.1894319763" superClass="com.qnx.qcc.inputType.compiler"/>
|
||||||
|
@ -500,7 +535,7 @@
|
||||||
</tool>
|
</tool>
|
||||||
<tool id="com.qnx.qcc.tool.linker.557662309" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
|
<tool id="com.qnx.qcc.tool.linker.557662309" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
|
||||||
<option id="com.qnx.qcc.option.linker.debug.2077179537" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
|
<option id="com.qnx.qcc.option.linker.debug.2077179537" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
|
||||||
<option id="com.qnx.qcc.option.linker.coverage.1300750623" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
|
<option id="com.qnx.qcc.option.linker.coverage.1300750623" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs -p)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
|
||||||
<option id="com.qnx.qcc.option.linker.shared.692015673" name="Shared (-shared)" superClass="com.qnx.qcc.option.linker.shared" value="true" valueType="boolean"/>
|
<option id="com.qnx.qcc.option.linker.shared.692015673" name="Shared (-shared)" superClass="com.qnx.qcc.option.linker.shared" value="true" valueType="boolean"/>
|
||||||
<option id="com.qnx.qcc.option.linker.langcpp.2076404861" name="C++ (-lang-c++)" superClass="com.qnx.qcc.option.linker.langcpp" value="true" valueType="boolean"/>
|
<option id="com.qnx.qcc.option.linker.langcpp.2076404861" name="C++ (-lang-c++)" superClass="com.qnx.qcc.option.linker.langcpp" value="true" valueType="boolean"/>
|
||||||
<option id="com.qnx.qcc.option.linker.security.1793451941" 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.security.1793451941" name="Enhanced Security (-Wl,-z,relro -Wl,-z,now)" superClass="com.qnx.qcc.option.linker.security" value="true" valueType="boolean"/>
|
||||||
|
|
|
@ -259,31 +259,33 @@ void CCLabelTTF::setFontName(const char *fontName)
|
||||||
// Helper
|
// Helper
|
||||||
bool CCLabelTTF::updateTexture()
|
bool CCLabelTTF::updateTexture()
|
||||||
{
|
{
|
||||||
|
bool bRet = false;
|
||||||
CCTexture2D *tex;
|
CCTexture2D *tex;
|
||||||
|
|
||||||
// let system compute label's width or height when its value is 0
|
do
|
||||||
// refer to cocos2d-x issue #1430
|
|
||||||
tex = new CCTexture2D();
|
|
||||||
tex->initWithString( m_string.c_str(),
|
|
||||||
m_pFontName->c_str(),
|
|
||||||
m_fFontSize * CC_CONTENT_SCALE_FACTOR(),
|
|
||||||
CC_SIZE_POINTS_TO_PIXELS(m_tDimensions),
|
|
||||||
m_hAlignment,
|
|
||||||
m_vAlignment);
|
|
||||||
|
|
||||||
if (! tex)
|
|
||||||
{
|
{
|
||||||
return false;
|
// let system compute label's width or height when its value is 0
|
||||||
}
|
// refer to cocos2d-x issue #1430
|
||||||
|
tex = new CCTexture2D();
|
||||||
|
CC_BREAK_IF(!tex);
|
||||||
|
|
||||||
|
bRet = tex->initWithString( m_string.c_str(),
|
||||||
|
m_pFontName->c_str(),
|
||||||
|
m_fFontSize * CC_CONTENT_SCALE_FACTOR(),
|
||||||
|
CC_SIZE_POINTS_TO_PIXELS(m_tDimensions),
|
||||||
|
m_hAlignment,
|
||||||
|
m_vAlignment);
|
||||||
|
CC_BREAK_IF(!bRet);
|
||||||
|
|
||||||
this->setTexture(tex);
|
this->setTexture(tex);
|
||||||
tex->release();
|
tex->release();
|
||||||
|
|
||||||
CCRect rect = CCRectZero;
|
CCRect rect = CCRectZero;
|
||||||
rect.size = m_pobTexture->getContentSize();
|
rect.size = m_pobTexture->getContentSize();
|
||||||
this->setTextureRect(rect);
|
this->setTextureRect(rect);
|
||||||
|
}while(false);
|
||||||
return true;
|
|
||||||
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "CCApplication.h"
|
#include "CCApplication.h"
|
||||||
|
#include "platform/CCFileUtils.h"
|
||||||
#include "CCDirector.h"
|
#include "CCDirector.h"
|
||||||
#include "CCEGLView.h"
|
#include "CCEGLView.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "platform/CCCommon.h"
|
#include "platform/CCCommon.h"
|
||||||
#include "platform/CCApplicationProtocol.h"
|
#include "platform/CCApplicationProtocol.h"
|
||||||
|
#include <string>
|
||||||
NS_CC_BEGIN;
|
NS_CC_BEGIN;
|
||||||
|
|
||||||
class CCRect;
|
class CCRect;
|
||||||
|
@ -63,11 +63,17 @@ public:
|
||||||
virtual TargetPlatform getTargetPlatform();
|
virtual TargetPlatform getTargetPlatform();
|
||||||
|
|
||||||
|
|
||||||
/* set the Resource root path */
|
/**
|
||||||
void setResourceRootPath(const char *pszRootResDir);
|
* Sets the Resource root path.
|
||||||
|
* @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPath() instead.
|
||||||
|
*/
|
||||||
|
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir);
|
||||||
|
|
||||||
/* get the Resource root path */
|
/**
|
||||||
const char *getResourceRootPath(void);
|
* Gets the Resource root path.
|
||||||
|
* @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPath() instead.
|
||||||
|
*/
|
||||||
|
CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,8 @@ void CCFileUtils::purgeFileUtils()
|
||||||
|
|
||||||
bool CCFileUtils::init()
|
bool CCFileUtils::init()
|
||||||
{
|
{
|
||||||
m_searchPathArray.push_back("");
|
m_strDefaultResRootPath = "app/native/Resources/";
|
||||||
|
m_searchPathArray.push_back(m_strDefaultResRootPath);
|
||||||
m_searchResolutionsOrderArray.push_back("");
|
m_searchResolutionsOrderArray.push_back("");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -71,13 +72,6 @@ void CCFileUtils::purgeCachedEntries()
|
||||||
|
|
||||||
std::string CCFileUtils::getPathForFilename(const std::string& filename, const std::string& resourceDirectory, const std::string& searchPath)
|
std::string CCFileUtils::getPathForFilename(const std::string& filename, const std::string& resourceDirectory, const std::string& searchPath)
|
||||||
{
|
{
|
||||||
std::string ret = CCApplication::sharedApplication()->getResourceRootPath();;
|
|
||||||
|
|
||||||
if (ret[ret.length()-1] != '\\' && ret[ret.length()-1] != '/')
|
|
||||||
{
|
|
||||||
ret += "/";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string file = filename;
|
std::string file = filename;
|
||||||
std::string file_path = "";
|
std::string file_path = "";
|
||||||
size_t pos = filename.find_last_of("/");
|
size_t pos = filename.find_last_of("/");
|
||||||
|
@ -101,9 +95,8 @@ std::string CCFileUtils::getPathForFilename(const std::string& filename, const s
|
||||||
path += "/";
|
path += "/";
|
||||||
}
|
}
|
||||||
path += file;
|
path += file;
|
||||||
ret += path;
|
|
||||||
|
|
||||||
return ret;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CCFileUtils::fullPathForFilename(const char* pszFileName)
|
std::string CCFileUtils::fullPathForFilename(const char* pszFileName)
|
||||||
|
@ -140,6 +133,7 @@ std::string CCFileUtils::fullPathForFilename(const char* pszFileName)
|
||||||
{
|
{
|
||||||
// Adding the full path to cache if the file was found.
|
// Adding the full path to cache if the file was found.
|
||||||
s_fullPathCache.insert(std::pair<std::string, std::string>(pszFileName, fullpath));
|
s_fullPathCache.insert(std::pair<std::string, std::string>(pszFileName, fullpath));
|
||||||
|
CCLOG("Returning path: %s", fullpath.c_str());
|
||||||
return fullpath;
|
return fullpath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,12 +201,46 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz
|
||||||
|
|
||||||
void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory)
|
void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory)
|
||||||
{
|
{
|
||||||
|
if (pszResourceDirectory == NULL) return;
|
||||||
m_obDirectory = pszResourceDirectory;
|
m_obDirectory = pszResourceDirectory;
|
||||||
if (m_obDirectory.size() > 0 && m_obDirectory[m_obDirectory.size() - 1] != '/')
|
std::vector<std::string> searchPaths = this->getSearchPath();;
|
||||||
|
searchPaths.insert(searchPaths.begin(), pszResourceDirectory);
|
||||||
|
this->setSearchPath(searchPaths);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCFileUtils::setSearchPath(const std::vector<std::string>& searchPaths)
|
||||||
|
{
|
||||||
|
bool bExistDefaultRootPath = false;
|
||||||
|
|
||||||
|
m_searchPathArray.clear();
|
||||||
|
for (std::vector<std::string>::const_iterator iter = searchPaths.begin(); iter != searchPaths.end(); ++iter)
|
||||||
{
|
{
|
||||||
m_obDirectory.append("/");
|
std::string strPrefix;
|
||||||
|
std::string path;
|
||||||
|
if ((*iter)[0] != '/')
|
||||||
|
{ // Not an absolute path
|
||||||
|
if (iter->find(m_strDefaultResRootPath) != 0)
|
||||||
|
{ // The path contains no default resource root path, insert the root path.
|
||||||
|
strPrefix = m_strDefaultResRootPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
path = strPrefix+(*iter);
|
||||||
|
if (path.length() > 0 && path[path.length()-1] != '/')
|
||||||
|
{
|
||||||
|
path += "/";
|
||||||
|
}
|
||||||
|
if (!bExistDefaultRootPath && path == m_strDefaultResRootPath)
|
||||||
|
{
|
||||||
|
bExistDefaultRootPath = true;
|
||||||
|
}
|
||||||
|
m_searchPathArray.push_back(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bExistDefaultRootPath)
|
||||||
|
{
|
||||||
|
CCLOG("Default root path doesn't exist, adding it.");
|
||||||
|
m_searchPathArray.push_back(m_strDefaultResRootPath);
|
||||||
}
|
}
|
||||||
m_searchPathArray.insert(m_searchPathArray.begin(), m_obDirectory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CCFileUtils::getWriteablePath()
|
std::string CCFileUtils::getWriteablePath()
|
||||||
|
|
|
@ -175,7 +175,8 @@ void CCFileUtils::purgeCachedEntries()
|
||||||
|
|
||||||
bool CCFileUtils::init()
|
bool CCFileUtils::init()
|
||||||
{
|
{
|
||||||
m_searchPathArray.push_back("");
|
m_strDefaultResRootPath = "";
|
||||||
|
m_searchPathArray.push_back(m_strDefaultResRootPath);
|
||||||
m_searchResolutionsOrderArray.push_back("");
|
m_searchResolutionsOrderArray.push_back("");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -218,7 +219,7 @@ void CCFileUtils::setSearchPath(const std::vector<std::string>& searchPaths)
|
||||||
}
|
}
|
||||||
if (!bExistDefault)
|
if (!bExistDefault)
|
||||||
{
|
{
|
||||||
m_searchPathArray.push_back("");
|
m_searchPathArray.push_back(m_strDefaultResRootPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,8 @@ void CCFileUtils::purgeCachedEntries()
|
||||||
|
|
||||||
bool CCFileUtils::init()
|
bool CCFileUtils::init()
|
||||||
{
|
{
|
||||||
m_searchPathArray.push_back("");
|
m_strDefaultResRootPath = "";
|
||||||
|
m_searchPathArray.push_back(m_strDefaultResRootPath);
|
||||||
m_searchResolutionsOrderArray.push_back("");
|
m_searchResolutionsOrderArray.push_back("");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -220,7 +221,7 @@ void CCFileUtils::setSearchPath(const std::vector<std::string>& searchPaths)
|
||||||
}
|
}
|
||||||
if (!bExistDefault)
|
if (!bExistDefault)
|
||||||
{
|
{
|
||||||
m_searchPathArray.push_back("");
|
m_searchPathArray.push_back(m_strDefaultResRootPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,8 @@ CCFileUtils* CCFileUtils::sharedFileUtils()
|
||||||
|
|
||||||
bool CCFileUtils::init()
|
bool CCFileUtils::init()
|
||||||
{
|
{
|
||||||
m_searchPathArray.push_back("");
|
m_strDefaultResRootPath = "";
|
||||||
|
m_searchPathArray.push_back(m_strDefaultResRootPath);
|
||||||
m_searchResolutionsOrderArray.push_back("");
|
m_searchResolutionsOrderArray.push_back("");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -76,13 +77,6 @@ void CCFileUtils::purgeCachedEntries()
|
||||||
|
|
||||||
std::string CCFileUtils::getPathForFilename(const std::string& filename, const std::string& resourceDirectory, const std::string& searchPath)
|
std::string CCFileUtils::getPathForFilename(const std::string& filename, const std::string& resourceDirectory, const std::string& searchPath)
|
||||||
{
|
{
|
||||||
std::string ret = "";
|
|
||||||
|
|
||||||
if (ret[ret.length()-1] != '\\' && ret[ret.length()-1] != '/')
|
|
||||||
{
|
|
||||||
ret += "/";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string file = filename;
|
std::string file = filename;
|
||||||
std::string file_path = "";
|
std::string file_path = "";
|
||||||
size_t pos = filename.find_last_of("/");
|
size_t pos = filename.find_last_of("/");
|
||||||
|
@ -106,9 +100,8 @@ std::string CCFileUtils::getPathForFilename(const std::string& filename, const s
|
||||||
path += "/";
|
path += "/";
|
||||||
}
|
}
|
||||||
path += file;
|
path += file;
|
||||||
ret += path;
|
|
||||||
|
|
||||||
return ret;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CCFileUtils::fullPathForFilename(const char* pszFileName)
|
std::string CCFileUtils::fullPathForFilename(const char* pszFileName)
|
||||||
|
@ -119,6 +112,7 @@ std::string CCFileUtils::fullPathForFilename(const char* pszFileName)
|
||||||
// Return directly if it's an absolute path.
|
// Return directly if it's an absolute path.
|
||||||
if (pszFileName[0] == '/')
|
if (pszFileName[0] == '/')
|
||||||
{
|
{
|
||||||
|
CCLOG("Return absolute path( %s ) directly.", pszFileName);
|
||||||
return pszFileName;
|
return pszFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,12 +192,46 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz
|
||||||
|
|
||||||
void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory)
|
void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory)
|
||||||
{
|
{
|
||||||
|
if (pszResourceDirectory == NULL) return;
|
||||||
m_obDirectory = pszResourceDirectory;
|
m_obDirectory = pszResourceDirectory;
|
||||||
if (m_obDirectory.size() > 0 && m_obDirectory[m_obDirectory.size() - 1] != '/')
|
std::vector<std::string> searchPaths = this->getSearchPath();;
|
||||||
|
searchPaths.insert(searchPaths.begin(), pszResourceDirectory);
|
||||||
|
this->setSearchPath(searchPaths);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCFileUtils::setSearchPath(const std::vector<std::string>& searchPaths)
|
||||||
|
{
|
||||||
|
bool bExistDefaultRootPath = false;
|
||||||
|
|
||||||
|
m_searchPathArray.clear();
|
||||||
|
for (std::vector<std::string>::const_iterator iter = searchPaths.begin(); iter != searchPaths.end(); ++iter)
|
||||||
{
|
{
|
||||||
m_obDirectory.append("/");
|
std::string strPrefix;
|
||||||
|
std::string path;
|
||||||
|
if ((*iter)[0] != '/')
|
||||||
|
{ // Not an absolute path
|
||||||
|
if (iter->find(m_strDefaultResRootPath) != 0)
|
||||||
|
{ // The path contains no default resource root path, insert the root path.
|
||||||
|
strPrefix = m_strDefaultResRootPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
path = strPrefix+(*iter);
|
||||||
|
if (path.length() > 0 && path[path.length()-1] != '/')
|
||||||
|
{
|
||||||
|
path += "/";
|
||||||
|
}
|
||||||
|
if (!bExistDefaultRootPath && path == m_strDefaultResRootPath)
|
||||||
|
{
|
||||||
|
bExistDefaultRootPath = true;
|
||||||
|
}
|
||||||
|
m_searchPathArray.push_back(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bExistDefaultRootPath)
|
||||||
|
{
|
||||||
|
CCLOG("Default root path doesn't exist, adding it.");
|
||||||
|
m_searchPathArray.push_back(m_strDefaultResRootPath);
|
||||||
}
|
}
|
||||||
m_searchPathArray.insert(m_searchPathArray.begin(), m_obDirectory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CCFileUtils::getWriteablePath()
|
std::string CCFileUtils::getWriteablePath()
|
||||||
|
|
|
@ -23,8 +23,6 @@ int main(int argc, char **argv)
|
||||||
height = 600;
|
height = 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCApplication::sharedApplication().setResourceRootPath("app/native/Resources/");
|
|
||||||
|
|
||||||
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
|
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
|
||||||
eglView.setSize(width, height);
|
eglView.setSize(width, height);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ int main(int argc, char **argv)
|
||||||
height = 600;
|
height = 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCApplication::sharedApplication()->setResourceRootPath("app/native/Resources/");
|
|
||||||
|
|
||||||
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||||
eglView->setFrameSize(width, height);
|
eglView->setFrameSize(width, height);
|
||||||
|
|
|
@ -25,7 +25,6 @@ int main(int argc, char **argv)
|
||||||
height = 600;
|
height = 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCApplication::sharedApplication()->setResourceRootPath("app/native/Resources/");
|
|
||||||
|
|
||||||
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||||
eglView->setFrameSize(width, height);
|
eglView->setFrameSize(width, height);
|
||||||
|
|
|
@ -23,8 +23,6 @@ int main(int argc, char **argv)
|
||||||
height = 600;
|
height = 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCApplication::sharedApplication()->setResourceRootPath("app/native/Resources/");
|
|
||||||
|
|
||||||
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||||
eglView->setFrameSize(width, height);
|
eglView->setFrameSize(width, height);
|
||||||
|
|
||||||
|
|
|
@ -465,6 +465,10 @@ files
|
||||||
ZwoptexTest.cpp
|
ZwoptexTest.cpp
|
||||||
ZwoptexTest.h
|
ZwoptexTest.h
|
||||||
|
|
||||||
|
[FileUtilsTest]
|
||||||
|
(../Classes/FileUtilsTest)
|
||||||
|
FileUtilsTest.cpp
|
||||||
|
FileUtilsTest.h
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,6 @@ int main(int argc, char **argv)
|
||||||
height = 600;
|
height = 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCApplication::sharedApplication()->setResourceRootPath("app/native/Resources/");
|
|
||||||
|
|
||||||
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||||
eglView->setFrameSize(width, height);
|
eglView->setFrameSize(width, height);
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,6 @@ int main(int argc, char **argv)
|
||||||
height = 600;
|
height = 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCApplication::sharedApplication()->setResourceRootPath("app/native/Resources/");
|
|
||||||
|
|
||||||
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||||
eglView->setFrameSize(width, height);
|
eglView->setFrameSize(width, height);
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,6 @@ int main(int argc, char **argv)
|
||||||
height = 600;
|
height = 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCApplication::sharedApplication()->setResourceRootPath("app/native/Resources/");
|
|
||||||
|
|
||||||
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||||
eglView->setFrameSize(width, height);
|
eglView->setFrameSize(width, height);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue