mirror of https://github.com/axmolengine/axmol.git
Merge pull request #1915 from dumganhar/master
Using full path in CCFileUtils::getFileData.
This commit is contained in:
commit
c7ef5a7683
|
@ -52,16 +52,16 @@ cd ".\Release.win32\"
|
|||
|
||||
set CC_TEST_BIN=TestCpp.exe
|
||||
|
||||
set CC_TEST_RES=..\samples\TestCpp\Resources
|
||||
set CC_HELLOWORLD_RES=..\samples\HelloCpp\Resources
|
||||
set CC_TESTLUA_RES=..\samples\TestLua\Resources
|
||||
set CC_SIMPLEGAME_RES=..\samples\SimpleGame\Resources
|
||||
set CC_HELLOLUA_RES=..\samples\HelloLua\Resources
|
||||
set CC_TEST_RES=..\samples\Cpp\TestCpp\Resources
|
||||
set CC_HELLOWORLD_RES=..\samples\Cpp\HelloCpp\Resources
|
||||
set CC_TESTLUA_RES=..\samples\Lua\TestLua\Resources
|
||||
set CC_SIMPLEGAME_RES=..\samples\Cpp\SimpleGame\Resources
|
||||
set CC_HELLOLUA_RES=..\samples\Lua\HelloLua\Resources
|
||||
set CC_JSB_SOURCES=..\scripting\javascript\bindings\js
|
||||
set CC_TESTJS_RES=..\samples\TestJavascript\cocos2d-js-tests\tests
|
||||
set CC_DRAGONJS_RES=..\samples\TestJavascript\cocos2d-js-tests\games\CocosDragonJS\Published files iOS
|
||||
set CC_MOONWARRIORS_RES=..\samples\TestJavascript\cocos2d-js-tests\games\MoonWarriors
|
||||
set CC_WATERMELONWITHME_RES=..\samples\TestJavascript\cocos2d-js-tests\games\WatermelonWithMe
|
||||
set CC_TESTJS_RES=..\samples\Javascript\Shared\tests
|
||||
set CC_DRAGONJS_RES=..\samples\Javascript\Shared\games\CocosDragonJS\Published files iOS
|
||||
set CC_MOONWARRIORS_RES=..\samples\Javascript\Shared\games\MoonWarriors
|
||||
set CC_WATERMELONWITHME_RES=..\samples\Javascript\Shared\games\WatermelonWithMe
|
||||
|
||||
|
||||
echo./*
|
||||
|
|
|
@ -6,6 +6,9 @@ EndProject
|
|||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosDenshion", "CocosDenshion\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "cocos2dx\proj.win32\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}"
|
||||
EndProject
|
||||
|
@ -77,6 +80,11 @@ EndProject
|
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project-lua", "project-lua", "{69C8AC8E-8B5C-474C-950D-1DB7F367E22C}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBinding", "scripting\javascript\bindings\proj.win32\libJSBinding.vcxproj", "{39379840-825A-45A0-B363-C09FFEF864BD}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28}
|
||||
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}
|
||||
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -149,21 +157,21 @@ Global
|
|||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{929480E7-23C0-4DF6-8456-096D71547116} = {F51B8DCB-62CD-441F-B85D-43BD8EA432F1}
|
||||
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {F51B8DCB-62CD-441F-B85D-43BD8EA432F1}
|
||||
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {F51B8DCB-62CD-441F-B85D-43BD8EA432F1}
|
||||
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F51B8DCB-62CD-441F-B85D-43BD8EA432F1}
|
||||
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {F51B8DCB-62CD-441F-B85D-43BD8EA432F1}
|
||||
{21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {F51B8DCB-62CD-441F-B85D-43BD8EA432F1}
|
||||
{B8BF9E81-35FD-4582-BA1C-B85FA365BABB} = {8DFE8821-1A1A-4894-9EA1-2A211F8CEDEA}
|
||||
{929480E7-23C0-4DF6-8456-096D71547116} = {F51B8DCB-62CD-441F-B85D-43BD8EA432F1}
|
||||
{13E55395-94A2-4CD9-BFC2-1A051F80C17D} = {69C8AC8E-8B5C-474C-950D-1DB7F367E22C}
|
||||
{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED} = {69C8AC8E-8B5C-474C-950D-1DB7F367E22C}
|
||||
{DDC3E27F-004D-4DD4-9DD3-931A013D2159} = {69C8AC8E-8B5C-474C-950D-1DB7F367E22C}
|
||||
{76A39BB2-9B84-4C65-98A5-654D86B86F2A} = {8DFE8821-1A1A-4894-9EA1-2A211F8CEDEA}
|
||||
{68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7} = {42FCBD79-852E-4A68-9C3F-51200BAF5732}
|
||||
{B8BF9E81-35FD-4582-BA1C-B85FA365BABB} = {8DFE8821-1A1A-4894-9EA1-2A211F8CEDEA}
|
||||
{1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2} = {42FCBD79-852E-4A68-9C3F-51200BAF5732}
|
||||
{D0F06A44-A245-4D13-A498-0120C203B539} = {42FCBD79-852E-4A68-9C3F-51200BAF5732}
|
||||
{BE092D9E-95AE-4F86-84CE-F4519E4F3F15} = {42FCBD79-852E-4A68-9C3F-51200BAF5732}
|
||||
{68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7} = {42FCBD79-852E-4A68-9C3F-51200BAF5732}
|
||||
{39379840-825A-45A0-B363-C09FFEF864BD} = {42FCBD79-852E-4A68-9C3F-51200BAF5732}
|
||||
{13E55395-94A2-4CD9-BFC2-1A051F80C17D} = {69C8AC8E-8B5C-474C-950D-1DB7F367E22C}
|
||||
{DDC3E27F-004D-4DD4-9DD3-931A013D2159} = {69C8AC8E-8B5C-474C-950D-1DB7F367E22C}
|
||||
{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED} = {69C8AC8E-8B5C-474C-950D-1DB7F367E22C}
|
||||
EndGlobalSection
|
||||
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
|
||||
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
|
||||
|
|
|
@ -155,15 +155,24 @@ public:
|
|||
*/
|
||||
void loadFilenameLookupDictionaryFromFile(const char* filename);
|
||||
|
||||
/** Loads the filenameLookup dictionary from the contents of a filename.
|
||||
|
||||
@since v2.1
|
||||
/**
|
||||
* Sets the filenameLookup dictionary.
|
||||
*
|
||||
* @param pFilenameLookupDict The dictionary for replacing filename.
|
||||
* @since v2.1
|
||||
*/
|
||||
void setFilenameLookupDictionary(CCDictionary* pFilenameLookupDict);
|
||||
|
||||
/// @cond
|
||||
/**
|
||||
* Gets full path from a file name and the path of the reletive file.
|
||||
* @param pszFilename The file name.
|
||||
* @param pszRelativeFile The path of the relative file.
|
||||
* @return The full path.
|
||||
* e.g. pszFilename: hello.png, pszRelativeFile: /User/path1/path2/hello.plist
|
||||
* Return: /User/path1/path2/hello.pvr (If there a a key(hello.png)-value(hello.pvr) in FilenameLookup dictionary. )
|
||||
*
|
||||
*/
|
||||
const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile);
|
||||
/// @endcond
|
||||
|
||||
/**
|
||||
@brief Set the resource directory; we will find resources relative to this directory.
|
||||
|
@ -173,24 +182,36 @@ public:
|
|||
CC_DEPRECATED_ATTRIBUTE void setResourceDirectory(const char *pszDirectoryName);
|
||||
|
||||
/**
|
||||
* Sets the array that contains the search order of the resources based for the device.
|
||||
* Sets the array that contains the search order of the resources.
|
||||
*
|
||||
* @param searchResolutionsOrder The source array that contains the search order of the resources.
|
||||
* @see getSearchResolutionsOrder().
|
||||
* @since v2.1
|
||||
*/
|
||||
void setSearchResolutionsOrder(const std::vector<std::string>& searchResolutionsOrder);
|
||||
|
||||
/**
|
||||
* Gets the array that contains the search order of the resources.
|
||||
*
|
||||
* @see setSearchResolutionsOrder().
|
||||
* @since v2.1
|
||||
*/
|
||||
const std::vector<std::string>& getSearchResolutionsOrder();
|
||||
|
||||
/**
|
||||
* Sets the array of search paths.
|
||||
* You can use this array to modify the search path of the resources.
|
||||
* If you want to use "themes" or search resources in the "cache", you can do it easily by adding new entries in this array.
|
||||
*
|
||||
* By default it is an array with only the "" (empty string) element.
|
||||
*
|
||||
*
|
||||
* @param searchPaths
|
||||
* @since v2.1
|
||||
*/
|
||||
void setSearchPath(const std::vector<std::string>& searchPaths);
|
||||
|
||||
/**
|
||||
* Gets the array of search paths.
|
||||
*
|
||||
*/
|
||||
const std::vector<std::string>& getSearchPath();
|
||||
|
||||
/**
|
||||
|
|
|
@ -161,13 +161,14 @@ const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const
|
|||
unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize)
|
||||
{
|
||||
unsigned char *buffer = 0;
|
||||
std::string full_path(pszFileName);
|
||||
|
||||
|
||||
if (!pszFileName || !pszMode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string full_path = fullPathForFilename(pszFileName);
|
||||
|
||||
do
|
||||
{
|
||||
// read from other path than user set it
|
||||
|
|
|
@ -425,7 +425,7 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz
|
|||
do
|
||||
{
|
||||
// read the file from hardware
|
||||
std::string fullPath = pszFileName;
|
||||
std::string fullPath = fullPathForFilename(pszFileName);
|
||||
FILE *fp = fopen(fullPath.c_str(), pszMode);
|
||||
CC_BREAK_IF(!fp);
|
||||
|
||||
|
|
|
@ -171,8 +171,9 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz
|
|||
|
||||
do
|
||||
{
|
||||
std::string fullPath = fullPathForFilename(pszFileName);
|
||||
// read rrom other path than user set it
|
||||
FILE *fp = fopen(pszFileName, pszMode);
|
||||
FILE *fp = fopen(fullPath.c_str(), pszMode);
|
||||
CC_BREAK_IF(!fp);
|
||||
|
||||
fseek(fp,0,SEEK_END);
|
||||
|
|
|
@ -424,8 +424,9 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz
|
|||
*pSize = 0;
|
||||
do
|
||||
{
|
||||
std::string fullPath = fullPathForFilename(pszFileName);
|
||||
// read the file from hardware
|
||||
FILE *fp = fopen(pszFileName, pszMode);
|
||||
FILE *fp = fopen(fullPath.c_str(), pszMode);
|
||||
CC_BREAK_IF(!fp);
|
||||
|
||||
fseek(fp,0,SEEK_END);
|
||||
|
|
|
@ -166,7 +166,9 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz
|
|||
{
|
||||
IW_CALLSTACK("CCFileUtils::getFileData");
|
||||
|
||||
s3eFile* pFile = s3eFileOpen(pszFileName, pszMode);
|
||||
std::string fullPath = fullPathForFilename(pszFileName);
|
||||
|
||||
s3eFile* pFile = s3eFileOpen(fullPath.c_str(), pszMode);
|
||||
|
||||
if (! pFile && isPopupNotify())
|
||||
{
|
||||
|
|
|
@ -182,8 +182,9 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz
|
|||
*pSize = 0;
|
||||
do
|
||||
{
|
||||
std::string fullPath = fullPathForFilename(pszFileName);
|
||||
// read the file from hardware
|
||||
FILE *fp = fopen(pszFileName, pszMode);
|
||||
FILE *fp = fopen(fullPath.c_str(), pszMode);
|
||||
CC_BREAK_IF(!fp);
|
||||
|
||||
fseek(fp,0,SEEK_END);
|
||||
|
@ -205,48 +206,48 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz
|
|||
return pBuffer;
|
||||
}
|
||||
|
||||
void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory)
|
||||
{
|
||||
if (pszResourceDirectory == NULL) return;
|
||||
m_obDirectory = pszResourceDirectory;
|
||||
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)
|
||||
{
|
||||
std::string strPrefix;
|
||||
std::string path;
|
||||
if (iter->length() > 1 && (*iter)[1] != ':')
|
||||
{ // 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[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);
|
||||
}
|
||||
void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory)
|
||||
{
|
||||
if (pszResourceDirectory == NULL) return;
|
||||
m_obDirectory = pszResourceDirectory;
|
||||
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)
|
||||
{
|
||||
std::string strPrefix;
|
||||
std::string path;
|
||||
if (iter->length() > 1 && (*iter)[1] != ':')
|
||||
{ // 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[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);
|
||||
}
|
||||
}
|
||||
|
||||
string CCFileUtils::getWriteablePath()
|
||||
|
|
Loading…
Reference in New Issue