Skip to content

Commit 77b0481

Browse files
authored
fix: paths contain non-ascii characters cause error (#381)
1 parent 5d5d231 commit 77b0481

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ios/lib/client/afc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class AFCClient extends ServiceClient<AFCProtocolClient> {
5252
async openFile(path: string): Promise<Buffer> {
5353
debug(`openFile: ${path}`);
5454
// mode + path + null terminator
55-
const data = Buffer.alloc(8 + path.length + 1);
55+
const data = Buffer.alloc(8 + Buffer.byteLength(path) + 1);
5656
// write mode
5757
data.writeUInt32LE(AFC_FILE_OPEN_FLAGS.WRONLY, 0);
5858
// then path to file
@@ -176,7 +176,7 @@ export class AFCClient extends ServiceClient<AFCProtocolClient> {
176176
}
177177

178178
function toCString(s: string) {
179-
const buf = Buffer.alloc(s.length + 1);
179+
const buf = Buffer.alloc(Buffer.byteLength(s) + 1);
180180
const len = buf.write(s);
181181
buf.writeUInt8(0, len);
182182
return buf;

0 commit comments

Comments
 (0)