Module file

Module file 

Source
Expand description

File I/O Operations for Seq

Provides file reading operations for Seq programs.

§Usage from Seq

"config.json" file-slurp  # ( String -- String ) read entire file
"config.json" file-exists?  # ( String -- Int ) 1 if exists, 0 otherwise
"data.txt" [ process-line ] file-for-each-line+  # ( String Quotation -- String Int )

§Example

: main ( -- Int )
  "config.json" file-exists? if
    "config.json" file-slurp write_line
  else
    "File not found" write_line
  then
  0
;

Re-exports§

pub use patch_seq_file_exists as file_exists;
pub use patch_seq_file_for_each_line_plus as file_for_each_line_plus;
pub use patch_seq_file_slurp as file_slurp;
pub use patch_seq_file_slurp_safe as file_slurp_safe;

Functions§

patch_seq_file_exists
Check if a file exists
patch_seq_file_for_each_line_plus
Process each line of a file with a quotation
patch_seq_file_slurp
Read entire file contents as a string
patch_seq_file_slurp_safe
Read entire file contents as a string, with error handling