more operations;
authorwenzelm
Wed, 09 Mar 2022 12:41:40 +0100
changeset 75251 598b4a1f61dc
parent 75250 e1dd62dd5540
child 75252 41dfe941c3da
more operations;
src/Tools/VSCode/extension/src/file.ts
--- a/src/Tools/VSCode/extension/src/file.ts	Wed Mar 09 11:29:34 2022 +0100
+++ b/src/Tools/VSCode/extension/src/file.ts	Wed Mar 09 12:41:40 2022 +0100
@@ -6,7 +6,8 @@
 'use strict';
 
 import * as path from 'path'
-import * as fs from 'fs/promises'
+import { readFile } from 'fs/promises'
+import { readFileSync } from 'fs'
 import { Buffer } from 'buffer'
 import * as platform from './platform'
 import * as library from './library'
@@ -135,7 +136,7 @@
 
 export async function read_bytes(path: string): Promise<Buffer>
 {
-    return fs.readFile(platform_path(path))
+    return readFile(platform_path(path))
 }
 
 export async function read(path: string): Promise<string>
@@ -147,3 +148,18 @@
 {
     return read(path).then(JSON.parse) as Promise<T>
 }
+
+export function read_bytes_sync(path: string): Buffer
+{
+  return readFileSync(platform_path(path))
+}
+
+export function read_sync(path: string): string
+{
+    return read_bytes_sync(path).toString()
+}
+
+export function read_json_sync<T>(path: string): T
+{
+    return JSON.parse(read_sync(path))
+}