authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-11 13:30:53 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-11 13:30:53 -07:00
log9cf5971c8e4d85e3bdce65496a183b85b53e423f
treee7f12b2b7995139bce24b2f0b3b481dbf03cadeb
parent98a31a81030224e13cb1977a8ef2792dfe478c8b

switch from `std.fs.Dir.realpathAlloc` to `std.fs.realpathAlloc`, cc #14

Thanks to @nfisher1226 for finding this fix :)

4 files changed, 7 insertions(+), 9 deletions(-)

src/cmd/init.zig+1-1
......@@ -7,7 +7,7 @@ const u = @import("./../util/index.zig");
77//
88
99pub fn execute(args: [][]u8) !void {
10 const name = u.detect_pkgname(u.try_index([]const u8, args, 0, ""), null) catch |err| switch (err) {
10 const name = u.detect_pkgname(u.try_index([]const u8, args, 0, ""), "") catch |err| switch (err) {
1111 error.NoBuildZig => {
1212 u.assert(false, "init requires a build.zig file", .{});
1313 unreachable;
src/common.zig+1-1
......@@ -229,7 +229,7 @@ pub fn get_module_from_dep(d: *u.Dep, dir: []const u8, parent_name: []const u8,
229229 return null;
230230 }
231231 const moddirO = try std.fs.cwd().openDir(moddir, .{});
232 const tryname = try u.detect_pkgname("", moddirO);
232 const tryname = try u.detect_pkgname("", moddir);
233233 const trymain = u.detct_mainfile("", moddirO, tryname) catch |err| switch (err) {
234234 error.CantFindMain => null,
235235 else => return err,
src/util/funcs.zig+3-3
......@@ -265,14 +265,14 @@ pub fn slice(comptime T: type, input: []const T, from: usize, to: usize) []const
265265 return input[f..t];
266266}
267267
268pub fn detect_pkgname(override: []const u8, dir: ?std.fs.Dir) ![]const u8 {
268pub fn detect_pkgname(override: []const u8, dir: []const u8) ![]const u8 {
269269 if (override.len > 0) {
270270 return override;
271271 }
272 if (!(try does_file_exist("build.zig", dir))) {
272 if (!(try does_file_exist("build.zig", try std.fs.cwd().openDir(dir, .{})))) {
273273 return error.NoBuildZig;
274274 }
275 const dpath = try (dir orelse std.fs.cwd()).realpathAlloc(gpa, "build.zig");
275 const dpath = try std.fs.realpathAlloc(gpa, try std.mem.concat(gpa, u8, &.{ dir, "build.zig" }));
276276 const splitP = try split(dpath, std.fs.path.sep_str);
277277 var name = splitP[splitP.len - 2];
278278 name = trim_prefix(name, "zig-");
src/util/modfile.zig+2-4
......@@ -26,10 +26,8 @@ pub const ModFile = struct {
2626 root_files: []const []const u8,
2727 files: []const []const u8,
2828
29 pub fn init(alloc: *std.mem.Allocator, fpath: []const u8) !Self {
30 //
31 const mpath = try std.fs.realpathAlloc(alloc, fpath);
32 const file = try std.fs.openFileAbsolute(mpath, .{});
29 pub fn init(alloc: *std.mem.Allocator, mpath: []const u8) !Self {
30 const file = try std.fs.cwd().openFile(mpath, .{});
3331 defer file.close();
3432 const input = try file.reader().readAllAlloc(alloc, mb);
3533 const doc = try yaml.parse(alloc, input);