purgeStoragePath added

This commit is contained in:
성낙호 2013-08-07 14:36:26 +09:00
parent 1c91e73a8c
commit 3fc48ecf15
2 changed files with 38 additions and 0 deletions

View File

@ -34,8 +34,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <dirent.h>
#endif
#include "support/zip_support/unzip.h"
using namespace cocos2d;
@ -644,4 +646,35 @@ AssetsManager* AssetsManager::create(const char* packageUrl, const char* version
return manager;
}
void AssetsManager::purgeStoragePath()
{
// Delete recorded version codes.
deleteVersion();
// Remove downloaded files
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32)
string command = "rm -r ";
// Path may include space.
command += "\"" + _storagePath + "\"";
system(command.c_str());
DIR *pDir = NULL;
pDir = opendir (_storagePath.c_str());
if (! pDir)
{
mkdir(_storagePath.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
}
#else
string command = "rd /s /q ";
// Path may include space.
command += "\"" + _storagePath + "\"";
system(command.c_str());
if ((GetFileAttributesA(_storagePath.c_str())) == INVALID_FILE_ATTRIBUTES)
{
CreateDirectoryA(_storagePath.c_str(), 0);
}
#endif
}
NS_CC_EXT_END;

View File

@ -147,6 +147,11 @@ public:
*/
friend int assetsManagerProgressFunc(void *, double, double, double, double);
/** @brief Initialize storage path.
*/
void purgeStoragePath();
protected:
bool downLoad();
void checkStoragePath();