1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

fix(std/wasi): path_filestat_get padding (#6509)

This commit is contained in:
Casper Beyer 2020-06-27 19:53:43 +08:00 committed by GitHub
parent 6c093c0b5a
commit 40dcfc8996
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 11 deletions

View file

@ -864,27 +864,27 @@ export default class Module {
switch (true) {
case info.isFile:
view.setUint8(buf_out, FILETYPE_REGULAR_FILE);
buf_out += 4;
buf_out += 8;
break;
case info.isDirectory:
view.setUint8(buf_out, FILETYPE_DIRECTORY);
buf_out += 4;
buf_out += 8;
break;
case info.isSymlink:
view.setUint8(buf_out, FILETYPE_SYMBOLIC_LINK);
buf_out += 4;
buf_out += 8;
break;
default:
view.setUint8(buf_out, FILETYPE_UNKNOWN);
buf_out += 4;
buf_out += 8;
break;
}
view.setUint32(buf_out, Number(info.nlink), true);
buf_out += 4;
buf_out += 8;
view.setBigUint64(buf_out, BigInt(info.size), true);
buf_out += 8;

View file

@ -3,26 +3,24 @@
fn main() {
let metadata = std::fs::metadata("/fixture/directory").unwrap();
assert!(metadata.is_dir());
assert!(metadata.len() > 0);
let metadata = std::fs::metadata("/fixture/symlink_to_directory").unwrap();
assert!(metadata.is_dir());
assert!(metadata.len() > 0);
let metadata = std::fs::metadata("/fixture/file").unwrap();
assert!(metadata.is_file());
assert!(metadata.len() > 0);
assert_eq!(metadata.len(), 5);
let metadata = std::fs::metadata("/fixture/symlink_to_file").unwrap();
assert!(metadata.is_file());
assert!(metadata.len() > 0);
assert_eq!(metadata.len(), 5);
let metadata = std::fs::metadata("/fixture/directory/file").unwrap();
assert!(metadata.is_file());
assert!(metadata.len() > 0);
assert_eq!(metadata.len(), 15);
let metadata =
std::fs::metadata("/fixture/directory/symlink_to_file").unwrap();
assert!(metadata.is_file());
assert!(metadata.len() > 0);
assert_eq!(metadata.len(), 15);
}