Skip to content

The result read_link is followed by an extra \0 #262

@Brooooooklyn

Description

@Brooooooklyn

Source code

use std::fs::read_link;

fn main() {
    let link = read_link("./link.txt").unwrap();
    println!("{:?}", link);
}
import { readFile } from 'node:fs/promises'
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { WASI } from 'node:wasi'

const wasi = new WASI({
  preopens: {
    '/': join(fileURLToPath(import.meta.url), '..'),
  },
  version: 'preview1',
  env: process.env,
})

const wasm = await WebAssembly.compile(
  await readFile(new URL('./target/wasm32-wasi/debug/wasi-read-link.wasm', import.meta.url))
)

const instance = await WebAssembly.instantiate(wasm, wasi.getImportObject())

wasi.start(instance)

wasmtime run --dir $(pwd)::/ target/wasm32-wasi/debug/wasi-read-link.wasm

node index.mjs

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions