mirror of
https://codeberg.org/andyscott/ziglings.git
synced 2024-12-22 14:03:10 -05:00
add patch files for 106_files.zig
This commit is contained in:
parent
23b11a7509
commit
74a6e60e17
2 changed files with 4 additions and 4 deletions
|
@ -35,8 +35,8 @@ pub fn main() !void {
|
||||||
// by doing nothing
|
// by doing nothing
|
||||||
//
|
//
|
||||||
// we want to catch error.PathAlreadyExists and do nothing
|
// we want to catch error.PathAlreadyExists and do nothing
|
||||||
??? => {
|
error.PathAlreadyExists => {
|
||||||
???
|
return;
|
||||||
},
|
},
|
||||||
// if is any other unexpected error we just propagate it through
|
// if is any other unexpected error we just propagate it through
|
||||||
else => return e,
|
else => return e,
|
||||||
|
@ -46,7 +46,7 @@ pub fn main() !void {
|
||||||
// wait a minute
|
// wait a minute
|
||||||
// opening a directory might fail!
|
// opening a directory might fail!
|
||||||
// what should we do here?
|
// what should we do here?
|
||||||
const output_dir: std.fs.Dir = cwd.openDir("output", .{});
|
const output_dir: std.fs.Dir = try cwd.openDir("output", .{});
|
||||||
|
|
||||||
// we try to open the file `zigling.txt`,
|
// we try to open the file `zigling.txt`,
|
||||||
// and propagate the error up if there are any errors
|
// and propagate the error up if there are any errors
|
||||||
|
@ -56,7 +56,7 @@ pub fn main() !void {
|
||||||
// but here we are not yet done writing to the file
|
// but here we are not yet done writing to the file
|
||||||
// if only there are a keyword in zig that
|
// if only there are a keyword in zig that
|
||||||
// allow you "defer" code execute to the end of scope...
|
// allow you "defer" code execute to the end of scope...
|
||||||
file.close();
|
defer file.close();
|
||||||
|
|
||||||
// !you are not allow to switch this two lines to before file closing line!
|
// !you are not allow to switch this two lines to before file closing line!
|
||||||
const byte_written = try file.write("It's zigling time!");
|
const byte_written = try file.write("It's zigling time!");
|
||||||
|
|
BIN
patches/patches/106_files.patch
Normal file
BIN
patches/patches/106_files.patch
Normal file
Binary file not shown.
Loading…
Reference in a new issue