authorgravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-12-15 06:23:46 -08:00
committergravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-12-15 06:23:46 -08:00
log111b88da9e3b4c4f5e1a3271f5befaa8abbf3146
treecaa1fa2b919dc52cd7930146dd232a38b4f3773c
parentc7d72c12f2c8e7a92e0a14d742c3a42755af8fb6

util: replace realpathalloc with openfile


1 files changed, 2 insertions(+), 7 deletions(-)

src/util/funcs.zig+2-7
......@@ -45,11 +45,7 @@ pub fn trim_prefix(in: []const u8, prefix: []const u8) []const u8 {
4545}
4646
4747pub fn does_file_exist(fpath: []const u8) !bool {
48 const abs_path = std.fs.realpathAlloc(gpa, fpath) catch |e| switch (e) {
49 error.FileNotFound => return false,
50 else => return e,
51 };
52 const file = std.fs.openFileAbsolute(abs_path, .{}) catch |e| switch (e) {
48 const file = std.fs.cwd().openFile(fpath, .{}) catch |e| switch (e) {
5349 error.FileNotFound => return false,
5450 else => return e,
5551 };
......@@ -58,11 +54,10 @@ pub fn does_file_exist(fpath: []const u8) !bool {
5854}
5955
6056pub fn does_folder_exist(fpath: []const u8) !bool {
61 const abs_path = std.fs.realpathAlloc(gpa, fpath) catch |e| switch (e) {
57 const file = try std.fs.cwd().openFile(abs_path, .{}) catch |e| switch (e) {
6258 error.FileNotFound => return false,
6359 else => return e,
6460 };
65 const file = try std.fs.openFileAbsolute(abs_path, .{});
6661 defer file.close();
6762 const s = try file.stat();
6863 if (s.kind != .Directory) {