diff --git a/cocos/platform/apple/CCFileUtils-apple.mm b/cocos/platform/apple/CCFileUtils-apple.mm index d51e284a4f..485d7cfe16 100644 --- a/cocos/platform/apple/CCFileUtils-apple.mm +++ b/cocos/platform/apple/CCFileUtils-apple.mm @@ -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; } diff --git a/extensions/assets-manager/AssetsManager.cpp b/extensions/assets-manager/AssetsManager.cpp index ef9e835371..aed2ac76a4 100644 --- a/extensions/assets-manager/AssetsManager.cpp +++ b/extensions/assets-manager/AssetsManager.cpp @@ -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 diff --git a/tests/lua-tests/project/Classes/lua_assetsmanager_test_sample.cpp b/tests/lua-tests/project/Classes/lua_assetsmanager_test_sample.cpp index d91fe7a8a6..b872a8c0a9 100644 --- a/tests/lua-tests/project/Classes/lua_assetsmanager_test_sample.cpp +++ b/tests/lua-tests/project/Classes/lua_assetsmanager_test_sample.cpp @@ -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; } diff --git a/tests/lua-tests/src/AssetsManagerTest/AssetsManagerTest.lua b/tests/lua-tests/src/AssetsManagerTest/AssetsManagerTest.lua index 3ea12a07f4..15f3db45e5 100644 --- a/tests/lua-tests/src/AssetsManagerTest/AssetsManagerTest.lua +++ b/tests/lua-tests/src/AssetsManagerTest/AssetsManagerTest.lua @@ -76,8 +76,7 @@ local function updateLayer() local function update(sender) progressLable:setString("") - - getAssetsManager():update() + getAssetsManager():checkUpdate() end local function reset(sender)