From 111b88da9e3b4c4f5e1a3271f5befaa8abbf3146 Mon Sep 17 00:00:00 2001 From: Meghan Date: Tue, 15 Dec 2020 06:23:46 -0800 Subject: [PATCH] util: replace realpathalloc with openfile --- src/util/funcs.zig | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/util/funcs.zig b/src/util/funcs.zig index 06ebf18cb3887ecd3ae4b72c6dea6cefe6192752..2c877df198b8ee1c28695dc0be5b7d1d38c8704a 100644 --- a/src/util/funcs.zig +++ b/src/util/funcs.zig @@ -45,11 +45,7 @@ pub fn trim_prefix(in: []const u8, prefix: []const u8) []const u8 { } pub fn does_file_exist(fpath: []const u8) !bool { - 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) { + const file = std.fs.cwd().openFile(fpath, .{}) catch |e| switch (e) { error.FileNotFound => return false, else => return e, }; @@ -58,11 +54,10 @@ pub fn does_file_exist(fpath: []const u8) !bool { } pub fn does_folder_exist(fpath: []const u8) !bool { - const abs_path = std.fs.realpathAlloc(gpa, fpath) catch |e| switch (e) { + const file = try std.fs.cwd().openFile(abs_path, .{}) catch |e| switch (e) { error.FileNotFound => return false, else => return e, }; - const file = try std.fs.openFileAbsolute(abs_path, .{}); defer file.close(); const s = try file.stat(); if (s.kind != .Directory) { -- 2.54.0