make compilable on windows
This commit is contained in:
12
src/main.zig
12
src/main.zig
@@ -1,7 +1,7 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const info = std.log.info;
|
const info = std.log.info;
|
||||||
const debug = std.log.debug;
|
const debug = std.log.debug;
|
||||||
const stderr = std.io.getStdErr().writer();
|
//const stderr = std.io.getStdErr().writer();
|
||||||
const print = std.debug.print;
|
const print = std.debug.print;
|
||||||
const eql = std.mem.eql;
|
const eql = std.mem.eql;
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
@@ -297,9 +297,9 @@ fn read_config(allocator: Allocator, config_location: []const u8) !ArrayList(Otp
|
|||||||
number_of_errors += 1;
|
number_of_errors += 1;
|
||||||
switch (err) {
|
switch (err) {
|
||||||
error.UnexpectedCharacter, error.InvalidFormat => {
|
error.UnexpectedCharacter, error.InvalidFormat => {
|
||||||
try stderr.print("Unexpected character in line {d} in file {s}. Line will be ignored.\n", .{ line_no, config_location });
|
try std.io.getStdErr().writer().print("Unexpected character in line {d} in file {s}. Line will be ignored.\n", .{ line_no, config_location });
|
||||||
if (number_of_errors >= 10) {
|
if (number_of_errors >= 10) {
|
||||||
try stderr.print("too many parsing errors\n", .{});
|
try std.io.getStdErr().writer().print("too many parsing errors\n", .{});
|
||||||
return ArgumentError.TooManyParsinErrors;
|
return ArgumentError.TooManyParsinErrors;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -322,13 +322,13 @@ fn read_config(allocator: Allocator, config_location: []const u8) !ArrayList(Otp
|
|||||||
error.BadPathName,
|
error.BadPathName,
|
||||||
error.InvalidWtf8,
|
error.InvalidWtf8,
|
||||||
=> {
|
=> {
|
||||||
try stderr.print("cannot open config file: {}\n", .{err});
|
try std.io.getStdErr().writer().print("cannot open config file: {}\n", .{err});
|
||||||
},
|
},
|
||||||
error.FileNotFound => {
|
error.FileNotFound => {
|
||||||
try stderr.print("config file not found. Create a new config file in $HOME/.zig-totp or $XDG_CONFIG_HOME/zig-totp.\n", .{});
|
try std.io.getStdErr().writer().print("config file not found. Create a new config file in $HOME/.zig-totp or $XDG_CONFIG_HOME/zig-totp.\n", .{});
|
||||||
},
|
},
|
||||||
error.IsDir => {
|
error.IsDir => {
|
||||||
try stderr.print("the configuration location must be a file, but is a directory.\n", .{});
|
try std.io.getStdErr().writer().print("the configuration location must be a file, but is a directory.\n", .{});
|
||||||
},
|
},
|
||||||
else => {
|
else => {
|
||||||
return err;
|
return err;
|
||||||
|
|||||||
Reference in New Issue
Block a user