sync_to_file


Description:

public abstract async void sync_to_file () throws Error

Sync current buffer contents to file (GTK buffers only).

Gets the current buffer contents and writes them to the file. Used when buffer contents have been modified via GTK operations (user typing, etc.) and need to be saved to disk.

Process

  1. Get current buffer contents

    2. Create backup if needed

    3. Write to file on disk

    4. Mark buffer as not modified

    5. Update file metadata

Support

  • GTK buffers: Fully supported
  • Dummy buffers: Not supported - throws IOError.NOT_SUPPORTED

Usage:

// For GTK buffers only
if (file.buffer is GtkSourceFileBuffer) {
yield file.buffer.sync_to_file();
}

Exceptions:

Error

if file cannot be written or method is not supported