From 9d53dab4df64361f00dda2534eecbd04797d56a2 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Mon, 12 Apr 2021 20:32:58 +0800 Subject: feat(runtime): add truncate and truncateSync methods to Deno.File (#10130) --- runtime/js/40_files.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'runtime/js/40_files.js') diff --git a/runtime/js/40_files.js b/runtime/js/40_files.js index 2ce495f8e..d552b4ba5 100644 --- a/runtime/js/40_files.js +++ b/runtime/js/40_files.js @@ -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); } -- cgit v1.2.3