write


Description:

public abstract async void write (string contents) throws Error

Write contents to buffer and file on disk.

Updates buffer contents and writes to file on disk. For files in database, creates backup before writing.

Process

  1. Update buffer contents (GTK buffer text or lines array)

    2. Create backup if file is in database (id > 0)

    3. Write to file on disk asynchronously

    4. Update file metadata (last_modified, last_viewed)

    5. Save to database

    6. Emit file.changed() signal

Backup Creation

  • Backups are now created by FileHistory.commit() before writes
  • Backup paths are stored in FileHistory.backup_path
  • Path: ~/.cache/ollmchat/edited/{timestamp}-{id}-{basename}

Usage:

try {
yield file.buffer.write(new_contents);
// File written and backup created (if needed)
} catch (Error e) {
// Handle error
}

Parameters:

contents

Contents to write

Exceptions:

Error

if file cannot be written