|
1 | 1 | const builtin = @import("builtin");
|
2 | 2 | const std = @import("std");
|
| 3 | +const config = @import("config"); |
3 | 4 |
|
4 | 5 | const Options = @import("Options.zig");
|
5 | 6 | const Tags = @import("Tags.zig");
|
@@ -37,15 +38,24 @@ pub fn main() anyerror!u8 {
|
37 | 38 | const full_fname = if (std.fs.path.isAbsolute(fname))
|
38 | 39 | try allocator.dupe(u8, fname)
|
39 | 40 | else
|
40 |
| - try std.fs.cwd().realpathAlloc(allocator, fname); |
| 41 | + std.fs.cwd().realpathAlloc(allocator, fname) catch |err| switch (err) { |
| 42 | + error.FileNotFound => { |
| 43 | + std.io.getStdErr().writer().print( |
| 44 | + "{s}: Cannot open {s}: File not found.\n", |
| 45 | + .{ config.name, fname }, |
| 46 | + ) catch {}; |
| 47 | + return 22; // EINVAL |
| 48 | + }, |
| 49 | + else => return err, |
| 50 | + }; |
41 | 51 | defer allocator.free(full_fname);
|
42 | 52 |
|
43 | 53 | tags.findTags(full_fname) catch |err| switch (err) {
|
44 |
| - error.NotFile => { |
45 |
| - try std.io.getStdErr().writer().print( |
46 |
| - "Error: {s} is a directory. Arguments must be Zig source files.\n", |
47 |
| - .{full_fname}, |
48 |
| - ); |
| 54 | + error.IsDir => { |
| 55 | + std.io.getStdErr().writer().print( |
| 56 | + "{s}: {s} is a directory. Arguments must be Zig source files.\n", |
| 57 | + .{ config.name, full_fname }, |
| 58 | + ) catch {}; |
49 | 59 | return 22; // EINVAL
|
50 | 60 | },
|
51 | 61 | else => return err,
|
|
0 commit comments