Skip to main content

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_dir_delete as dir_delete;
pub use patch_seq_dir_exists as dir_exists;
pub use patch_seq_dir_list as dir_list;
pub use patch_seq_dir_make as dir_make;
pub use patch_seq_file_append as file_append;
pub use patch_seq_file_delete as file_delete;
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_size as file_size;
pub use patch_seq_file_slurp as file_slurp;
pub use patch_seq_file_spit as file_spit;

Functions§

patch_seq_dir_delete
Delete an empty directory
patch_seq_dir_exists
Check if a directory exists
patch_seq_dir_list
List directory contents
patch_seq_dir_make
Create a directory (and parent directories if needed)
patch_seq_file_append
Append string to file (creates if doesn’t exist)
patch_seq_file_delete
Delete a file
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_size
Get file size in bytes
patch_seq_file_slurp
Read entire file contents as a string
patch_seq_file_spit
Write string to file (creates or overwrites)