未验证 提交 ed7eaa15 编写于 作者: O openharmony_ci 提交者: Gitee

!16249 【回合beta5】bugfix fs buf2string 打印

Merge pull request !16249 from zhuhongtao666/cherry-pick-1679277480
...@@ -600,7 +600,7 @@ read(fd: number, buffer: ArrayBuffer, options?: { offset?: number; length?: numb ...@@ -600,7 +600,7 @@ read(fd: number, buffer: ArrayBuffer, options?: { offset?: number; length?: numb
let buf = new ArrayBuffer(4096); let buf = new ArrayBuffer(4096);
fs.read(file.fd, buf).then((readLen) => { fs.read(file.fd, buf).then((readLen) => {
console.info("read file data succeed"); console.info("read file data succeed");
console.info(String.fromCharCode.apply(null, new Uint8Array(readLen))); console.info(String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen))));
fs.closeSync(file); fs.closeSync(file);
}).catch((err) => { }).catch((err) => {
console.info("read file data failed with error message: " + err.message + ", error code: " + err.code); console.info("read file data failed with error message: " + err.message + ", error code: " + err.code);
...@@ -635,7 +635,7 @@ read(fd: number, buffer: ArrayBuffer, options?: { offset?: number; length?: numb ...@@ -635,7 +635,7 @@ read(fd: number, buffer: ArrayBuffer, options?: { offset?: number; length?: numb
console.info("mkdir failed with error message: " + err.message + ", error code: " + err.code); console.info("mkdir failed with error message: " + err.message + ", error code: " + err.code);
} else { } else {
console.info("read file data succeed"); console.info("read file data succeed");
console.info(String.fromCharCode.apply(null, new Uint8Array(readLen))); console.info(String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen))));
fs.closeSync(file); fs.closeSync(file);
} }
}); });
...@@ -2273,7 +2273,7 @@ read(buffer: ArrayBuffer, options?: { offset?: number; length?: number; }): Prom ...@@ -2273,7 +2273,7 @@ read(buffer: ArrayBuffer, options?: { offset?: number; length?: number; }): Prom
let buf = new ArrayBuffer(4096); let buf = new ArrayBuffer(4096);
ss.read(buf, {offset: 5, length: 5}).then((readLen) => { ss.read(buf, {offset: 5, length: 5}).then((readLen) => {
console.info("read data succeed"); console.info("read data succeed");
console.log(String.fromCharCode.apply(null, new Uint8Array(buf))); console.log(String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen))));
}).catch((err) => { }).catch((err) => {
console.info("read data failed with error message: " + err.message + ", error code: " + err.code); console.info("read data failed with error message: " + err.message + ", error code: " + err.code);
}); });
...@@ -2307,7 +2307,7 @@ read(buffer: ArrayBuffer, options?: { position?: number; offset?: number; length ...@@ -2307,7 +2307,7 @@ read(buffer: ArrayBuffer, options?: { position?: number; offset?: number; length
console.info("read stream failed with error message: " + err.message + ", error code: " + err.code); console.info("read stream failed with error message: " + err.message + ", error code: " + err.code);
} else { } else {
console.info("read data succeed"); console.info("read data succeed");
console.log(String.fromCharCode.apply(null, new Uint8Array(buf))); console.log(String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen))));
} }
}); });
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册