Skip to main content

write

Function write 

Source
pub fn write(path: String, content: String) -> Result<(), String>
Expand description

Writes a string to a file.

Creates the file if it doesn’t exist, truncates it if it does. Parent directories must already exist.

§Arguments

  • path - Path to the file (relative or absolute)
  • content - Content to write

§Errors

Returns an error if:

  • Parent directory doesn’t exist
  • File can’t be created or written (permissions, I/O error)

§Example

use logicaffeine_system::file;

file::write("output.txt".to_string(), "Result: 42".to_string())?;