summaryrefslogtreecommitdiff
path: root/src/fs.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs.zig')
-rw-r--r--src/fs.zig8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/fs.zig b/src/fs.zig
index a0092991..d90bb8c0 100644
--- a/src/fs.zig
+++ b/src/fs.zig
@@ -457,11 +457,15 @@ fn resolveVirtual(p: ?*pardes.Pardes, path: []const u8, out: *[4096]u8) ?Resolve
return null;
}
-pub fn read(p: *pardes.Pardes, path: []const u8) ![]u8 {
+/// What reading a file through the namespace fails with: the disk's, a
+/// peer's (Client.readMount), the served tree's.
+pub const ReadError = error{ Timeout, WriteFailed, PermissionDenied, FileNotFound, ReadFailed, OutOfMemory, Dial, BadDial, FileTooLarge, NodeCollision, TooManyFiles, OpenFailed, NotAFile, PathTooLong, IsDirectory, PathTooDeep, Hangup, Botch, Remote, NotFound };
+
+pub fn read(p: *pardes.Pardes, path: []const u8) ReadError![]u8 {
return readLimit(p, path, limits.max_file_bytes);
}
-pub fn readLimit(p: *pardes.Pardes, path: []const u8, max_bytes: usize) ![]u8 {
+pub fn readLimit(p: *pardes.Pardes, path: []const u8, max_bytes: usize) ReadError![]u8 {
const limit = @min(max_bytes, limits.max_file_bytes);
if (std.mem.eql(u8, std.mem.trimEnd(u8, path, "/"), "/n")) {
var out: std.Io.Writer.Allocating = .init(p.gpa);