Move tmp file to original
This commit is contained in:
parent
8145ff694b
commit
f755e0aeec
1 changed files with 15 additions and 2 deletions
|
@ -3,7 +3,7 @@ const util = @import("util.zig");
|
||||||
|
|
||||||
const hosts_header = "# local-etc-hosts-updater";
|
const hosts_header = "# local-etc-hosts-updater";
|
||||||
|
|
||||||
const FILE_LINE_BUFF_SIZE = 50;
|
const FILE_LINE_BUFF_SIZE = 100;
|
||||||
|
|
||||||
pub fn update_hosts(ip: util.IP) !void {
|
pub fn update_hosts(ip: util.IP) !void {
|
||||||
try create_tmp_hosts(ip);
|
try create_tmp_hosts(ip);
|
||||||
|
@ -107,4 +107,17 @@ fn create_tmp_hosts(ip: util.IP) !void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_tmp_hosts() !void {}
|
fn move_tmp_hosts() !void {
|
||||||
|
var target_hosts = try std.fs.createFileAbsoluteZ(try util.getenv("OLD_HOSTS_PATH"), .{ .lock = .exclusive });
|
||||||
|
defer target_hosts.close();
|
||||||
|
const target_writer = target_hosts.writer();
|
||||||
|
var tmp_hosts = try std.fs.openFileAbsoluteZ(try util.getenv("TMP_HOSTS_PATH"), .{});
|
||||||
|
defer tmp_hosts.close();
|
||||||
|
const source_reader = tmp_hosts.reader();
|
||||||
|
|
||||||
|
source_reader.streamUntilDelimiter(target_writer, 0x00, null) catch |err| {
|
||||||
|
if (err != error.EndOfStream) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue