From c5ebada6142a458968c9ff0676612eae8bdae8c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=94=E5=8F=BD=E5=92=8C=E7=8C=AA=E6=89=92?= Date: Mon, 24 Mar 2025 11:18:23 +0800 Subject: [PATCH] rmdir_async MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 兔叽和猪扒 --- .../js/src/mod_fs/ani/ets/@ohos.file.fs.ets | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/interfaces/kits/js/src/mod_fs/ani/ets/@ohos.file.fs.ets b/interfaces/kits/js/src/mod_fs/ani/ets/@ohos.file.fs.ets index 67eb95add..a0fa25f4e 100644 --- a/interfaces/kits/js/src/mod_fs/ani/ets/@ohos.file.fs.ets +++ b/interfaces/kits/js/src/mod_fs/ani/ets/@ohos.file.fs.ets @@ -329,6 +329,29 @@ function rmdirSync(path: string): void { return FileIoImpl.rmdirSync(path) } +function rmdir(path: string): Promise { + return new Promise((resolve: (result: undefined) => void, + reject: (e: BusinessError) => void): void => { + let promise = taskpool.execute((path: string): void => FileIoImpl.rmdirSync(path), path); + promise.then((ret: NullishType) => { + resolve(undefined); + }).catch((e: BusinessError): void => { + reject(e); + }); + }); +} + +function rmdir(path: string, callback: AsyncCallback): void { + let promise = taskpool.execute((path: string): void => FileIoImpl.rmdirSync(path), path); + promise.then((ret: NullishType) => { + let e = new BusinessError(); + e.code = 0; + callback(e, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); + }); +} + function truncateSync(file: string | number, len?: number): void { return FileIoImpl.truncateSync(file, len) } -- Gitee