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 @@...@@ -1,5 +1,6 @@
1const std = @import("std");1const std = @import("std");
2const gpa = std.heap.c_allocator;2const gpa = std.heap.c_allocator;
3const fs = std.fs;
34
4const known_folders = @import("known-folders");5const known_folders = @import("known-folders");
5const u = @import("./util/index.zig");6const u = @import("./util/index.zig");
...@@ -10,12 +11,12 @@ const u = @import("./util/index.zig");...@@ -10,12 +11,12 @@ const u = @import("./util/index.zig");
10pub fn execute(args: [][]u8) !void {11pub fn execute(args: [][]u8) !void {
11 //12 //
12 const home = try known_folders.getPath(gpa, .home);13 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
15 const top_module = try fetch_deps(dir, "./zig.mod");16 const top_module = try fetch_deps(dir, "./zig.mod");
1617
17 //18 //
18 const f = try std.fs.cwd().createFile("./deps.zig", .{});19 const f = try fs.cwd().createFile("./deps.zig", .{});
19 defer f.close();20 defer f.close();
2021
21 const w = f.writer();22 const w = f.writer();
...@@ -155,7 +156,7 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module {...@@ -155,7 +156,7 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module {
155 };156 };
156}157}
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 {
159 if (m.deps.len == 0 and tabs > 0) {160 if (m.deps.len == 0 and tabs > 0) {
160 try w.print("null", .{});161 try w.print("null", .{});
161 return;162 return;
...@@ -178,8 +179,8 @@ fn print_deps(w: std.fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32) an...@@ -178,8 +179,8 @@ fn print_deps(w: std.fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32) an
178 try w.print("{}", .{try u.concat(&[_][]const u8{r,"}"})});179 try w.print("{}", .{try u.concat(&[_][]const u8{r,"}"})});
179}180}
180181
181fn print_incl_dirs_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8), local: bool) anyerror!void {
182 if (u.list_contains(list, mod.clean_path)) {182 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 {
183 return;184 return;
184 }185 }
185 try list.append(mod.clean_path);186 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...@@ -195,8 +196,8 @@ fn print_incl_dirs_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList
195 }196 }
196}197}
197198
198fn print_csrc_dirs_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8), local: bool) anyerror!void {
199 if (u.list_contains(list, mod.clean_path)) {199 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 {
200 return;201 return;
201 }202 }
202 try list.append(mod.clean_path);203 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...@@ -212,8 +213,8 @@ fn print_csrc_dirs_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList
212 }213 }
213}214}
214215
215fn print_csrc_flags_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8), local: bool) anyerror!void {
216 if (u.list_contains(list, mod.clean_path)) {216 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 {
217 return;218 return;
218 }219 }
219 try list.append(mod.clean_path);220 try list.append(mod.clean_path);