Hi, I have this function
fn hasGitIgnore(absolute_path: []const u8) bool {
const file_name = if (absolute_path[absolute_path.len - 1] == '/') ".gitignore" else "/.gitignore";
var buf: [255]u8 = undefined;
const gitIgnorePath = std.fmt.bufPrint(&buf, "{s}{s}", .{ absolute_path, file_name }) catch "";
var file = std.fs.openFileAbsolute(gitIgnorePath, .{}) catch {
return false;
};
defer file.close();
return true;
}
It's currently using openFileAbsolute to check if the file exists.
Is there a better way to do this?
I've heard about Dir.access, but the purpose of this function requires taking in a string, not a Dir 🤔