Skip to main content

file_create

Function file_create 

Source
pub fn file_create(
    path: &Path,
    content: &str,
    force: bool,
    mode: ApplyMode,
    guard: Option<&PathGuard>,
) -> Result<EditResult>
Expand description

Create a new file with the given content.

If force is false, fails when the file already exists ([EditErrorKind::AlreadyExists]).

When force is true and the path already holds binary, invalid UTF-8, or otherwise unreadable prior content, the create overwrites with empty original for backup/diff (no host-side remove+recreate). PathGuard still applies. Apply writes use the normal hardlink-preserving commit path (#1962).