Skip to content

FileFlush

Description

Flush any kernel-side buffering for the file. On POSIX with no user-side buffering this is a no-op success unless the platform needs an fsync (we don’t fsync today; callers that need durable writes should fsync the fd themselves). On Windows it calls FlushFileBuffers.

Success

Returns true.

Failure

Returns false.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    bool FileFlush(File *f) {
        if (!FileIsOpen(f)) {
            return false;
        }
    
        if (ok && !FileFlush(stream)) {
            LOG_ERROR("Failed to flush formatted output");
            ok = false;
    // truthy would make the closed case wrongly report success.
    bool test_fm_347_flush_open_vs_closed(void) {
        WriteFmt("Testing FileFlush returns true open / false closed (open gate)\n");
    
        DefaultAllocator alloc      = DefaultAllocatorInit();
        }
        // Open handle flushes true.
        bool ok = (FileFlush(&f) == true);
        FileClose(&f);
        // Closed handle must flush false (the open gate fires).
        FileClose(&f);
        // Closed handle must flush false (the open gate fires).
        ok = ok && (FileFlush(&f) == false);
    
        FileRemove(&path);
Last updated on