authorgravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-11-29 04:01:43 -08:00
committergravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-11-29 04:01:43 -08:00
log5ef889d8843b678cb40574e111e03040c095c7c6
tree40b80f7ea44750c930f6b037d076ebec1aae87dc
parente5869c1ed3c5e22c888a1400b46460f30f83d6de

fetch: use fs instead of std.fs


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

src/cmd_fetch.zig+7-6
......@@ -1,5 +1,6 @@
11const std = @import("std");
22const gpa = std.heap.c_allocator;
3const fs = std.fs;
34
45const known_folders = @import("known-folders");
56const u = @import("./util/index.zig");
......@@ -10,12 +11,12 @@ const u = @import("./util/index.zig");
1011pub fn execute(args: [][]u8) !void {
1112 //
1213 const home = try known_folders.getPath(gpa, .home);
13 const dir = try std.fs.path.join(gpa, &[_][]const u8{home.?, ".cache", "zigmod", "deps"});
14 const dir = try fs.path.join(gpa, &[_][]const u8{home.?, ".cache", "zigmod", "deps"});
1415
1516 const top_module = try fetch_deps(dir, "./zig.mod");
1617
1718 //
18 const f = try std.fs.cwd().createFile("./deps.zig", .{});
19 const f = try fs.cwd().createFile("./deps.zig", .{});
1920 defer f.close();
2021
2122 const w = f.writer();
......@@ -155,7 +156,7 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module {
155156 };
156157}
157158
158fn print_deps(w: std.fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32) anyerror!void {
159fn print_deps(w: fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32) anyerror!void {
159160 if (m.deps.len == 0 and tabs > 0) {
160161 try w.print("null", .{});
161162 return;
......@@ -178,8 +179,8 @@ fn print_deps(w: std.fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32) an
178179 try w.print("{}", .{try u.concat(&[_][]const u8{r,"}"})});
179180}
180181
181fn print_incl_dirs_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8), local: bool) anyerror!void {
182182 if (u.list_contains(list, mod.clean_path)) {
183fn print_incl_dirs_to(w: fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8), local: bool) anyerror!void {
183184 return;
184185 }
185186 try list.append(mod.clean_path);
......@@ -195,8 +196,8 @@ fn print_incl_dirs_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList
195196 }
196197}
197198
198fn print_csrc_dirs_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8), local: bool) anyerror!void {
199199 if (u.list_contains(list, mod.clean_path)) {
200fn print_csrc_dirs_to(w: fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8), local: bool) anyerror!void {
200201 return;
201202 }
202203 try list.append(mod.clean_path);
......@@ -212,8 +213,8 @@ fn print_csrc_dirs_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList
212213 }
213214}
214215
215fn print_csrc_flags_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8), local: bool) anyerror!void {
216216 if (u.list_contains(list, mod.clean_path)) {
217fn print_csrc_flags_to(w: fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8), local: bool) anyerror!void {
217218 return;
218219 }
219220 try list.append(mod.clean_path);