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)
{
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;
}

View File

@ -63,6 +63,7 @@ AssetsManager::AssetsManager(const char* packageUrl/* =nullptr */, const char* v
, _isDownloading(false)
, _shouldDeleteDelegateWhenExit(false)
{
checkStoragePath();
// convert downloader error code to AssetsManager::ErrorCode
_downloader->onTaskError = [this](const DownloadTask& task,
int errorCode,
@ -145,7 +146,7 @@ AssetsManager::AssetsManager(const char* packageUrl/* =nullptr */, const char* v
// start download;
const string outFileName = _storagePath + TEMP_PACKAGE_FILE_NAME;
_downloader->createDownloadFileTask(_packageUrl, _storagePath);
_downloader->createDownloadFileTask(_packageUrl, outFileName);
};
// 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
CCLOG("'lua_cocos2dx_deleteDownloadDir' not implemented on tvOS");
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
FileUtils::getInstance()->removeDirectory(pathToSave);
return 0;
}

View File

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