CnxFile struct
#include <include/Cnx/filesystem/File.h>
Cnx type used to manage reading and writing to/from a file, the buffering associated with the file, and closing it when it's no longer used.
Example:
#include <Cnx/filesystem/File.h> void example(void) { let_mut maybe_file = cnx_file_open("my_file.txt"); cnx_assert(cnx_result_is_ok(maybe_file), "Failed to open my_file.txt"); CnxScopedFile file = cnx_result_unwrap(maybe_file); let my_important_number = 42; let my_important_float 24.0F; cnx_file_println(&file, "number: {}, float: {}", my_important_number, my_important_float); let_mut maybe_file2 = cnx_file_open("my_other_file.txt"); cnx_assert(cnx_result_is_ok(maybe_file2), "Failed to open my_other_file.txt"); CnxScopedFile file2 = cnx_result_unwrap(maybe_file2); let_mut maybe_read = cnx_file_read_line(&file2); if(cnx_result_is_ok(maybe_read)) { CnxScopedString str = cnx_result_unwrap(maybe_read); // do something with the line read from `my_other_file.txt` } // files automatically closed when they leave scope because they were declared as // `CnxScopedFile` }