Skip to content

FileWrite

Description

Write up to n bytes from buf. Same short-write semantics as FileRead.

Success

Returns the number of bytes written (>= 0).

Failure

Returns -1 on error.

Usage example (Cross-references)

Usage examples (Cross-references)
        }
    
        if (ok && out.length > 0 && FileWrite(stream, out.data, out.length) != (i64)out.length) {
            LOG_ERROR("Failed to write formatted output");
            ok = false;
    
        File out = (type == LOG_MESSAGE_TYPE_INFO) ? FileFromFd(1) : FileFromFd(2);
        (void)FileWrite(&out, full.data, full.length);
    
        if (type == LOG_MESSAGE_TYPE_FATAL) {
            Str        trace = StrInit(a);
            FormatStackTrace(&trace, frames, n, a);
            (void)FileWrite(&out, trace.data, trace.length);
            StrDeinit(&trace);
        }
    }
    
    i64 FileWrite(File *f, const void *buf, u64 n) {
        if (!FileIsValid(f) || !buf) {
            return -1;
Last updated on