diff --git a/services/file_extension_hap/entry/src/main/ets/FileExtensionAbility/FileExtensionAbility.ts b/services/file_extension_hap/entry/src/main/ets/FileExtensionAbility/FileExtensionAbility.ts index 1a16573b1eea995a9ca7a39ffa5b80295662a202..2821b12ec7530b72c17a11d5b3fbefe9f4fd01de 100644 --- a/services/file_extension_hap/entry/src/main/ets/FileExtensionAbility/FileExtensionAbility.ts +++ b/services/file_extension_hap/entry/src/main/ets/FileExtensionAbility/FileExtensionAbility.ts @@ -768,6 +768,23 @@ export default class FileExtAbility extends Extension { return `file://docs/storage/hmdfs/${path}`; } + getHmdfsPath(): {}[] { + let rootPathHmdfs = '/storage/hmdfs'; + let hmdfsInfoList = []; + let hmdfsName = fs.listFileSync(rootPathHmdfs); + for (let i = 0; i < hmdfsName.length; i++) { + let hmdfsInfo = { + uri: this.hmdfsPath2uri(hmdfsName[i]), + displayName: hmdfsName[i], + relativePath: '/storage/hmdfs/' + hmdfsName[i], + deviceType: deviceType.DEVICE_SHARED_TERMINAL, + deviceFlags: deviceFlag.SUPPORTS_READ | deviceFlag.SUPPORTS_WRITE, + }; + hmdfsInfoList.push(hmdfsInfo); + } + return hmdfsInfoList; + } + getRoots() { let roots = [ { @@ -802,20 +819,7 @@ export default class FileExtAbility extends Extension { roots = roots.concat(volumeInfoList); try { - let rootPathHmdfs = '/storage/hmdfs'; - let hmdfsInfoList = []; - let hmdfsName = fs.listFileSync(rootPathHmdfs); - for (let i = 0; i < hmdfsName.length; i++) { - let hmdfsInfo = { - uri: this.hmdfsPath2uri(hmdfsName[i]), - displayName: hmdfsName[i], - relativePath: '/storage/hmdfs/' + hmdfsName[i], - deviceType: deviceType.DEVICE_SHARED_TERMINAL, - deviceFlags: deviceFlag.SUPPORTS_READ | deviceFlag.SUPPORTS_WRITE, - }; - hmdfsInfoList.push(hmdfsInfo); - } - roots = roots.concat(hmdfsInfoList); + roots = roots.concat(getHmdfsPath()); } catch (e) { hilog.info(DOMAIN_CODE, TAG, 'getRoots errorcode: ' + e.code, ' message: ' + e.message); }