main_code.js 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. (function () {
  2. if (typeof window.jsb === 'object') {
  3. var hotUpdateSearchPaths = localStorage.getItem('HotUpdateSearchPaths');
  4. if (hotUpdateSearchPaths) {
  5. var paths = JSON.parse(hotUpdateSearchPaths);
  6. jsb.fileUtils.setSearchPaths(paths);
  7. var fileList = [];
  8. var storagePath = paths[0] || '';
  9. var tempPath = storagePath + '_temp/';
  10. var baseOffset = tempPath.length;
  11. if (jsb.fileUtils.isDirectoryExist(tempPath) && !jsb.fileUtils.isFileExist(tempPath + 'project.manifest.temp')) {
  12. jsb.fileUtils.listFilesRecursively(tempPath, fileList);
  13. fileList.forEach(srcPath => {
  14. var relativePath = srcPath.substr(baseOffset);
  15. var dstPath = storagePath + relativePath;
  16. if (srcPath[srcPath.length] === '/') {
  17. jsb.fileUtils.createDirectory(dstPath);
  18. } else {
  19. if (jsb.fileUtils.isFileExist(dstPath)) {
  20. jsb.fileUtils.removeFile(dstPath);
  21. }
  22. jsb.fileUtils.renameFile(srcPath, dstPath);
  23. }
  24. });
  25. jsb.fileUtils.removeDirectory(tempPath);
  26. }
  27. }
  28. }
  29. })();