From 231f4cc6c3e910a1217926a4a2e26ade242775e1 Mon Sep 17 00:00:00 2001 From: "zhoulisheng1@huawei.com" Date: Tue, 25 Apr 2023 10:54:12 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=9B=B4=E6=96=B0FileUtils,=20readFilePic?= =?UTF-8?q?=E6=B2=A1=E6=9C=89closeSync=E6=96=87=E4=BB=B6=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E9=80=A0=E6=88=90=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhoulisheng1@huawei.com --- .../src/main/ets/components/cache/FileUtils.ets | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/imageknife/src/main/ets/components/cache/FileUtils.ets b/imageknife/src/main/ets/components/cache/FileUtils.ets index 4a6af85..18ffe3c 100644 --- a/imageknife/src/main/ets/components/cache/FileUtils.ets +++ b/imageknife/src/main/ets/components/cache/FileUtils.ets @@ -111,18 +111,10 @@ export class FileUtils { */ writeData(path: string, content: ArrayBuffer | string) { try { - console.info("FileUtils - writeData size 1= " + path) let fd = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE).fd - console.info("FileUtils - writeData size 2= ") let stat = fs.statSync(path) - console.info("FileUtils - writeData size = " + stat.size) + console.info("FileUtils - writeData size = " + stat.size +" path="+path); fs.writeSync(fd, content, { offset: stat.size }) - let length = 0 - if (content instanceof ArrayBuffer) { - length = content.byteLength - } else { - length = content.length - } fs.closeSync(fd) } catch (e) { console.log("FileUtils - Failed to writeData for " + e) @@ -172,13 +164,11 @@ export class FileUtils { readFilePic(path: string): ArrayBuffer { try { let stat = fs.statSync(path) - console.info("FileUtils - readFilePic 1") let fd = fs.openSync(path, fs.OpenMode.READ_WRITE).fd; - let length = fs.statSync(path).size - console.info("FileUtils - readFilePic 2 length = " + length) + let length = stat.size let buf = new ArrayBuffer(length); - console.info("FileUtils - readFilePic 3") fs.readSync(fd, buf) + fs.closeSync(fd) return buf } catch (e) { console.log("FileUtils - readFilePic " + e)