feat(runtime): add truncate and truncateSync methods to Deno.File (#10130)

This commit is contained in:
Casper Beyer 2021-04-12 20:32:58 +08:00 committed by GitHub
parent da9219341f
commit 9d53dab4df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 1 deletions

View file

@ -4,7 +4,7 @@
((window) => {
const core = window.Deno.core;
const { read, readSync, write, writeSync } = window.__bootstrap.io;
const { fstat, fstatSync } = window.__bootstrap.fs;
const { ftruncate, ftruncateSync, fstat, fstatSync } = window.__bootstrap.fs;
const { pathFromURL } = window.__bootstrap.util;
function seekSync(
@ -88,6 +88,14 @@
return writeSync(this.rid, p);
}
truncate(len) {
return ftruncate(this.rid, len);
}
truncateSync(len) {
return ftruncateSync(this.rid, len);
}
read(p) {
return read(this.rid, p);
}