Merge pull request #15916 from dumganhar/fix/AssetsManager

fix AssetsManager could not work after Pull Request #13893 was merged.
This commit is contained in:
minggo 2016-06-22 15:25:18 +08:00 committed by GitHub
commit 9fd190d283
4 changed files with 7 additions and 16 deletions

View File

@ -299,9 +299,9 @@ static int unlink_cb(const char *fpath, const struct stat *sb, int typeflag, str
bool FileUtilsApple::removeDirectory(const std::string& path) bool FileUtilsApple::removeDirectory(const std::string& path)
{ {
if (path.size() > 0 && path[path.size() - 1] != '/') if (path.empty())
{ {
CCLOGERROR("Fail to remove directory, path must terminate with '/': %s", path.c_str()); CCLOGERROR("Fail to remove directory, path is empty!");
return false; return false;
} }

View File

@ -63,6 +63,7 @@ AssetsManager::AssetsManager(const char* packageUrl/* =nullptr */, const char* v
, _isDownloading(false) , _isDownloading(false)
, _shouldDeleteDelegateWhenExit(false) , _shouldDeleteDelegateWhenExit(false)
{ {
checkStoragePath();
// convert downloader error code to AssetsManager::ErrorCode // convert downloader error code to AssetsManager::ErrorCode
_downloader->onTaskError = [this](const DownloadTask& task, _downloader->onTaskError = [this](const DownloadTask& task,
int errorCode, int errorCode,
@ -145,7 +146,7 @@ AssetsManager::AssetsManager(const char* packageUrl/* =nullptr */, const char* v
// start download; // start download;
const string outFileName = _storagePath + TEMP_PACKAGE_FILE_NAME; const string outFileName = _storagePath + TEMP_PACKAGE_FILE_NAME;
_downloader->createDownloadFileTask(_packageUrl, _storagePath); _downloader->createDownloadFileTask(_packageUrl, outFileName);
}; };
// after download package, do uncompress operation // after download package, do uncompress operation

View File

@ -76,18 +76,9 @@ static int lua_cocos2dx_deleteDownloadDir(lua_State* L)
// Not implemented. "system" is not present on tvOS // Not implemented. "system" is not present on tvOS
CCLOG("'lua_cocos2dx_deleteDownloadDir' not implemented on tvOS"); CCLOG("'lua_cocos2dx_deleteDownloadDir' not implemented on tvOS");
return 0; return 0;
#elif (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32)
std::string command = "rm -r ";
// Path may include space.
command += "\"" + pathToSave + "\"";
system(command.c_str());
#else
std::string command = "rd /s /q ";
// Path may include space.
command += "\"" + pathToSave + "\"";
system(command.c_str());
#endif #endif
FileUtils::getInstance()->removeDirectory(pathToSave);
return 0; return 0;
} }

View File

@ -76,8 +76,7 @@ local function updateLayer()
local function update(sender) local function update(sender)
progressLable:setString("") progressLable:setString("")
getAssetsManager():checkUpdate()
getAssetsManager():update()
end end
local function reset(sender) local function reset(sender)