feat: persist file mode
This commit is contained in:
parent
ba39527dc9
commit
6fcfa85605
|
@ -106,6 +106,7 @@ fn genfile(
|
||||||
|
|
||||||
var content: []const u8 = undefined;
|
var content: []const u8 = undefined;
|
||||||
var fname: ?[]const u8 = null;
|
var fname: ?[]const u8 = null;
|
||||||
|
var file_mode: std.fs.File.Mode = std.fs.File.default_mode;
|
||||||
switch (file.content) {
|
switch (file.content) {
|
||||||
.string => |s| content = s,
|
.string => |s| content = s,
|
||||||
.path => |p| {
|
.path => |p| {
|
||||||
|
@ -113,6 +114,7 @@ fn genfile(
|
||||||
const path = try std.fs.path.join(std.heap.c_allocator, &.{ state.rootpath, p });
|
const path = try std.fs.path.join(std.heap.c_allocator, &.{ state.rootpath, p });
|
||||||
defer std.heap.c_allocator.free(path);
|
defer std.heap.c_allocator.free(path);
|
||||||
|
|
||||||
|
file_mode = (try std.fs.cwd().statFile(path)).mode;
|
||||||
const f = try std.fs.cwd().openFile(path, .{});
|
const f = try std.fs.cwd().openFile(path, .{});
|
||||||
defer f.close();
|
defer f.close();
|
||||||
|
|
||||||
|
@ -143,7 +145,7 @@ fn genfile(
|
||||||
try std.fs.cwd().makePath(dir);
|
try std.fs.cwd().makePath(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
var outfile = try std.fs.cwd().createFile(path, .{});
|
var outfile = try std.fs.cwd().createFile(path, .{ .mode = file_mode });
|
||||||
defer outfile.close();
|
defer outfile.close();
|
||||||
|
|
||||||
try outfile.writeAll(out);
|
try outfile.writeAll(out);
|
||||||
|
|
Loading…
Reference in a new issue