Skip to content

Commit

Permalink
fix: paths contain non-ascii characters cause error (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtarnawsky committed Jan 25, 2024
1 parent 5d5d231 commit 77b0481
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ios/lib/client/afc.ts
Expand Up @@ -52,7 +52,7 @@ export class AFCClient extends ServiceClient<AFCProtocolClient> {
async openFile(path: string): Promise<Buffer> {
debug(`openFile: ${path}`);
// mode + path + null terminator
const data = Buffer.alloc(8 + path.length + 1);
const data = Buffer.alloc(8 + Buffer.byteLength(path) + 1);
// write mode
data.writeUInt32LE(AFC_FILE_OPEN_FLAGS.WRONLY, 0);
// then path to file
Expand Down Expand Up @@ -176,7 +176,7 @@ export class AFCClient extends ServiceClient<AFCProtocolClient> {
}

function toCString(s: string) {
const buf = Buffer.alloc(s.length + 1);
const buf = Buffer.alloc(Buffer.byteLength(s) + 1);
const len = buf.write(s);
buf.writeUInt8(0, len);
return buf;
Expand Down

0 comments on commit 77b0481

Please sign in to comment.