issue #434,Refactor class CCFileUtils on platform airplay.

This commit is contained in:
natural-law 2011-03-28 16:27:26 +08:00
parent cee82fe9fa
commit ed2566e201
5 changed files with 25 additions and 62 deletions

View File

@ -116,11 +116,6 @@ files
("cocos2dx/support/data_support")
[support/data_support]
"*.h"
("cocos2dx/support/file_support")
[support/file_support]
"*.h"
"*.cpp"
("cocos2dx/support/image_support")
[support/image_support]

View File

@ -24,6 +24,8 @@ THE SOFTWARE.
#include "CCFileUtils.h"
#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS && CC_TARGET_PLATFORM != CC_PLATFORM_AIRPLAY)
#include <stack>
#include <libxml/parser.h>
#include <libxml/tree.h>
@ -33,8 +35,6 @@ THE SOFTWARE.
#include "CCSAXParser.h"
#include "support/zip_support/unzip.h"
#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS)
NS_CC_BEGIN;
typedef enum

View File

@ -4,7 +4,6 @@
#include "expat.h"
#include "CCString.h"
#include "support/file_support/FileData.h"
#include "support/zip_support/unzip.h"
#include "../CCSAXParser.h"
#include "CCApplication.h"
@ -219,5 +218,28 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz
return (unsigned char*)pDataToBeReadBinary;
}
std::string& CCFileUtils::ccRemoveHDSuffixFromFile(std::string& path)
{
#if CC_IS_RETINA_DISPLAY_SUPPORTED
if( CC_CONTENT_SCALE_FACTOR() == 2 )
{
std::string::size_type pos = path.rfind("/") + 1; // the begin index of last part of path
std::string::size_type suffixPos = path.rfind(CC_RETINA_DISPLAY_FILENAME_SUFFIX);
if (std::string::npos != suffixPos && suffixPos > pos)
{
CCLog("cocos2d: FilePath(%s) contains suffix(%s), remove it.", path.c_str(),
CC_RETINA_DISPLAY_FILENAME_SUFFIX);
path.replace(suffixPos, strlen(CC_RETINA_DISPLAY_FILENAME_SUFFIX), "");
}
}
#endif // CC_IS_RETINA_DISPLAY_SUPPORTED
return path;
}
NS_CC_END;

View File

@ -1,53 +0,0 @@
#ifndef __PLATFORM_AIRPLAY_CCFILE_UTILS_H__
#define __PLATFORM_AIRPLAY_CCFILE_UTILS_H__
#include "string.h"
#include "CCMutableDictionary.h"
#include "FileUtils.h"
NS_CC_BEGIN;
//! @brief Helper class to handle file operations
class CC_DLL CCFileUtils : public FileUtils
{
public:
/**
@brief Generate the absolute path of the file.
@param pszRelativePath The relative path of the file.
@return The absolute path of the file.
@warning We only add the ResourcePath before the relative path of the file.
If you have not set the ResourcePath,the function add "/NEWPLUS/TDA_DATA/UserData/" as default.
You can set ResourcePath by function void setResourcePath(const char *pszResourcePath);
*/
static const char* fullPathFromRelativePath(const char *pszRelativePath);
/// @cond
static const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile);
/// @endcond
/**
@brief Generate a NSDictionary pointer by file
@param pFileName The file name of *.plist file
@return The NSDictionary pointer generated from the file
*/
static CCDictionary<std::string, CCObject*> *dictionaryWithContentsOfFile(const char *pFileName);
/**
@brief Get resource file data
@param[in] pszFileName The resource file name which contain the path
@param[in] pszMode The read mode of the file
@param[out] pSize If get the file data succeed the it will be the data size,or it will be 0
@return if success,the pointer of data will be returned,or NULL is returned
@warning If you get the file data succeed,you must delete it after used.
*/
static unsigned char* getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize);
private:
// static std::string m_sRelativePath;
// static std::string m_sResourcePath;
};
NS_CC_END;
#endif // __PLATFORM_UPHONE_CCFILE_UTILS_H__

View File

@ -15,7 +15,6 @@
#endif
#include "ioapi.h"
#include "CCCommon.h"
namespace cocos2d {