Closed
Description
I tried this code:
//! This is src/bin/metadata.rs.
//! Compiled to wasm32-unknown-emscripten.
//! My codes are in <https://github.com/TheVeryDarkness/wasm-emscripten-fs-bug>.
use std::fs::{create_dir, metadata, read_dir, write};
fn main() {
create_dir("workspace");
write("workspace/a.txt", "I'm a.\n").unwrap();
write("workspace/b.txt", "This is b.\n").unwrap();
for file in read_dir("workspace").unwrap() {
let file = file.unwrap();
println!("{:?}", file.path());
let meta = file.metadata().unwrap();
println!("{:?}", meta);
println!("{}", meta.len());
}
let meta = metadata("workspace").unwrap();
println!("{:?}", meta);
// This seems to be the same with permission code.
println!("{:?}", meta.file_type());
println!("{}", meta.is_dir());
println!("{}", meta.is_file());
println!("{}", meta.is_symlink());
}
I expected to see this happen: got correct file_type()
and len()
.
Instead, this happened: file_type()
returns permission code, while len()
returns created time..
Meta
rustc --version --verbose
:
wasm_emscripten_fs_bug % rustc +nightly --version --verbose
rustc 1.77.0-nightly (d6d7a9386 2023-12-22)
binary: rustc
commit-hash: d6d7a93866f2ffcfb51828b8859bdad760b54ce0
commit-date: 2023-12-22
host: aarch64-apple-darwin
release: 1.77.0-nightly
LLVM version: 17.0.6
Backtrace
No panic here, so there's no RUST_BACKTRACE.
Running with RUST_BACKTRACE=1 cargo +nightly run -Zbuild-std --target wasm32-unknown-emscripten --release -vv --bin metadata
.