From 98d4a1c3ed812fdd3db3482fe83a77c44cc58e21 Mon Sep 17 00:00:00 2001 From: Meghan Date: Mon, 16 Nov 2020 17:58:19 -0800 Subject: [PATCH] util: add another catch case to does_file_exist --- src/util/funcs.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util/funcs.zig b/src/util/funcs.zig index 118543164d75eae76a6a60e9072166c8756a8d38..8cc3dc4cba7b60f44b2f823f82d4c201b0e0702f 100644 --- a/src/util/funcs.zig +++ b/src/util/funcs.zig @@ -41,7 +41,10 @@ pub fn trim_prefix(in: []const u8, prefix: []const u8) []const u8 { } pub fn does_file_exist(fpath: []const u8) !bool { - const abs_path = try std.fs.realpathAlloc(gpa, fpath); + const abs_path = std.fs.realpathAlloc(gpa, fpath) catch |e| switch (e) { + error.FileNotFound => return false, + else => return e, + }; const file = std.fs.openFileAbsolute(abs_path, .{}) catch |e| switch (e) { error.FileNotFound => return false, else => return e, -- 2.54.0