Skip to content

Modern Fs File Sync

Paul Squires edited this page Oct 22, 2026 · 3 revisions

Home › Filesystem › File Streams › File.Sync

File.Sync

Forces the file's data and metadata onto the disk, so a write survives a power cut.

Syntax

File.Sync( )

Notes

  • Writes the file's data and metadata through to the disk (FlushFileBuffers, fsync). What makes a write survive a power cut.

Examples

#import "std/fs"
using fs

dim as ustring dir_ = CreateTempDir( "tkdoc" ).Value( )
dim as ustring p = PathJoin( dir_, "f.txt" )
dim as File f
f.Create( p )
f.WriteUtf8( "durable" )
print f.Sync( ).IsOk( )    '' true
f.Close( )

RemoveDirAll( dir_ )

Library: Filesystem Library Category: File Streams Documented under: Files

Clone this wiki locally