mirror of https://github.com/axmolengine/axmol.git
Merge pull request #15916 from dumganhar/fix/AssetsManager
fix AssetsManager could not work after Pull Request #13893 was merged.
This commit is contained in:
commit
9fd190d283
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,8 +76,7 @@ local function updateLayer()
|
|||
|
||||
local function update(sender)
|
||||
progressLable:setString("")
|
||||
|
||||
getAssetsManager():update()
|
||||
getAssetsManager():checkUpdate()
|
||||
end
|
||||
|
||||
local function reset(sender)
|
||||
|
|
Loading…
Reference in New Issue