authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-28 03:34:33 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-28 03:34:33 -07:00
log5eeb1f37ad0f488b2c9b615b9590650ef4fd0f82
tree1cd11fab9a87ffefa02f070c29de5e7aa58ae571
parente0e95bedc45c574fef385e7f6a7a2253d1614108

fix order of util.does_file_exist signature


3 files changed, 10 insertions(+), 10 deletions(-)

src/cmd/aquila/install.zig+1-1
......@@ -13,7 +13,7 @@ pub fn execute(args: [][]u8) !void {
1313 const homepath = home.?;
1414 const homedir = try std.fs.cwd().openDir(homepath, .{});
1515
16 if (!(try u.does_file_exist("zig.mod", homedir))) {
16 if (!(try u.does_file_exist(homedir, "zig.mod"))) {
1717 const f = try homedir.createFile("zig.mod", .{});
1818 defer f.close();
1919 const w = f.writer();
src/cmd/init.zig+3-3
......@@ -78,7 +78,7 @@ pub fn execute(args: [][]u8) !void {
7878 if (try u.does_folder_exist(".git")) {
7979 const do = try inquirer.forConfirm(stdout, stdin, "It appears you're using git. Do you want init to add Zigmod to your .gitignore?", gpa);
8080 if (do) {
81 const exists = try u.does_file_exist(".gitignore", null);
81 const exists = try u.does_file_exist(null, ".gitignore");
8282 const file: std.fs.File = try (if (exists) cwd.openFile(".gitignore", .{ .read = true, .write = true }) else cwd.createFile(".gitignore", .{}));
8383 defer file.close();
8484 const len = try file.getEndPos();
......@@ -94,7 +94,7 @@ pub fn execute(args: [][]u8) !void {
9494 }
9595
9696 // ask about LICENSE
97 if (!(try u.does_file_exist("LICENSE", null))) {
97 if (!(try u.does_file_exist(null, "LICENSE"))) {
9898 if (detectlicense.licenses.find(license)) |text| {
9999 if (try inquirer.forConfirm(stdout, stdin, "It appears you don't have a LICENSE file defined, would you like init to add it for you?", gpa)) {
100100 var realtext = text;
......@@ -141,7 +141,7 @@ pub fn writeLibManifest(w: std.fs.File.Writer, id: string, name: string, entry:
141141
142142fn guessCopyrightName() !?string {
143143 const home = (try knownfolders.open(gpa, .home, .{})).?;
144 if (!(try u.does_file_exist(".gitconfig", home))) return null;
144 if (!(try u.does_file_exist(home, ".gitconfig"))) return null;
145145 const file = try home.openFile(".gitconfig", .{});
146146 const content = try file.reader().readAllAlloc(gpa, 1024 * 1024);
147147 var iniO = try ini.parseIntoMap(content, gpa);
src/util/funcs.zig+6-6
......@@ -55,7 +55,7 @@ pub fn trim_prefix(in: string, prefix: string) string {
5555 return in;
5656}
5757
58pub fn does_file_exist(fpath: string, dir: ?std.fs.Dir) !bool {
58pub fn does_file_exist(dir: ?std.fs.Dir, fpath: string) !bool {
5959 const file = (dir orelse std.fs.cwd()).openFile(fpath, .{}) catch |e| switch (e) {
6060 error.FileNotFound => return false,
6161 error.IsDir => return true,
......@@ -263,7 +263,7 @@ pub fn detect_pkgname(override: string, dir: string) !string {
263263 return override;
264264 }
265265 const dirO = if (dir.len == 0) std.fs.cwd() else try std.fs.cwd().openDir(dir, .{});
266 if (!(try does_file_exist("build.zig", dirO))) {
266 if (!(try does_file_exist(dirO, "build.zig"))) {
267267 return error.NoBuildZig;
268268 }
269269 const dpath = try std.fs.realpathAlloc(gpa, try std.mem.concat(gpa, u8, &.{ dir, "build.zig" }));
......@@ -276,20 +276,20 @@ pub fn detect_pkgname(override: string, dir: string) !string {
276276
277277pub fn detct_mainfile(override: string, dir: ?std.fs.Dir, name: string) !string {
278278 if (override.len > 0) {
279 if (try does_file_exist(override, dir)) {
279 if (try does_file_exist(dir, override)) {
280280 if (std.mem.endsWith(u8, override, ".zig")) {
281281 return override;
282282 }
283283 }
284284 }
285285 const namedotzig = try std.mem.concat(gpa, u8, &.{ name, ".zig" });
286 if (try does_file_exist(namedotzig, dir)) {
286 if (try does_file_exist(dir, namedotzig)) {
287287 return namedotzig;
288288 }
289 if (try does_file_exist(try std.fs.path.join(gpa, &.{ "src", "lib.zig" }), dir)) {
289 if (try does_file_exist(dir, try std.fs.path.join(gpa, &.{ "src", "lib.zig" }))) {
290290 return "src/lib.zig";
291291 }
292 if (try does_file_exist(try std.fs.path.join(gpa, &.{ "src", "main.zig" }), dir)) {
292 if (try does_file_exist(dir, try std.fs.path.join(gpa, &.{ "src", "main.zig" }))) {
293293 return "src/main.zig";
294294 }
295295 return error.CantFindMain;