106_files.zig format

This commit is contained in:
Alan CHUNG 2024-03-25 16:36:15 +08:00
parent 66d08f1e1f
commit 23b11a7509

View file

@ -8,13 +8,13 @@
// The File System provide a hierarchical structure for storing files // The File System provide a hierarchical structure for storing files
// by organizing files into directories, which hold files and other directories, // by organizing files into directories, which hold files and other directories,
// thus creating a tree structure for navigating. // thus creating a tree structure for navigating.
// //
// Fortunately, zig standard library provide a simple api for interacting // Fortunately, zig standard library provide a simple api for interacting
// with the file system, see the detail documentation here // with the file system, see the detail documentation here
// //
// https://ziglang.org/documentation/master/std/#std.fs // https://ziglang.org/documentation/master/std/#std.fs
// //
// In this exercise, we'll try to // In this exercise, we'll try to
// - create a new directory // - create a new directory
// - open a file in the directory // - open a file in the directory
// - write to the file. // - write to the file.
@ -67,14 +67,14 @@ pub fn main() !void {
// 2. print the content of the file in the console with command // 2. print the content of the file in the console with command
// >> cat ./output/zigling.txt // >> cat ./output/zigling.txt
// //
// //
// More on Creating files // More on Creating files
// //
// notice in: // notice in:
// ... try output_dir.createFile("zigling.txt", .{}); // ... try output_dir.createFile("zigling.txt", .{});
// ^^^ // ^^^
// we passed this anonymous struct to the function call // we passed this anonymous struct to the function call
// //
// this is the struct `CreateFlag` with default fields // this is the struct `CreateFlag` with default fields
// { // {
// read: bool = false, // read: bool = false,
@ -84,7 +84,7 @@ pub fn main() !void {
// lock_nonblocking: bool = false, // lock_nonblocking: bool = false,
// mode: Mode = default_mode // mode: Mode = default_mode
// } // }
// //
// Question: // Question:
// - what should you do if you want to also read the file after opening it? // - what should you do if you want to also read the file after opening it?
// - go to documentation of the struct `std.fs.Dir` here // - go to documentation of the struct `std.fs.Dir` here