aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/fs.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/nvim-lsp-installer/fs.lua')
-rw-r--r--lua/nvim-lsp-installer/fs.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer/fs.lua b/lua/nvim-lsp-installer/fs.lua
index 38ac053f..3725f154 100644
--- a/lua/nvim-lsp-installer/fs.lua
+++ b/lua/nvim-lsp-installer/fs.lua
@@ -101,6 +101,17 @@ function M.write_file(path, contents)
assert(uv.fs_close(fd))
end
+---@param path string @The full path to the file to read.
+function M.read_file(path)
+ log.fmt_debug("fs: read_file %s", path)
+ assert_ownership(path)
+ local fd = assert(uv.fs_open(path, "r", 438))
+ local fstat = assert(uv.fs_fstat(fd))
+ local contents = assert(uv.fs_read(fd, fstat.size, 0))
+ assert(uv.fs_close(fd))
+ return contents
+end
+
function M.append_file(path, contents)
log.fmt_debug("fs: append_file %s", path)
assert_ownership(path)