Skip to content

FileClose

Description

Close a file we opened via FileOpen. Idempotent and safe on a borrowed (owns == false) handle; in that case it just clears the local state without touching the underlying fd / HANDLE.

Success

Returns true.

Failure

Returns false if the close syscall failed (logged).

Usage example (Cross-references)

Usage examples (Cross-references)
            return false;
        }
        FileClose(&f);
        return true;
    }
            return false;
        }
        FileClose(&f);
        return true;
    }
            return false;
        }
        FileClose(&f);
        return true;
    }
            if (!StrReserve(&out->raw, grown_to)) {
                LOG_ERROR("ProcMapsLoad: failed to grow buffer");
                FileClose(&f);
                ProcMapsDeinit(out);
                return false;
            if (n < 0) {
                LOG_ERROR("ProcMapsLoad: FileRead failed");
                FileClose(&f);
                ProcMapsDeinit(out);
                return false;
                break; // EOF
        }
        FileClose(&f);
        if (out->raw.length == 0) {
            LOG_ERROR("ProcMapsLoad: /proc/self/maps was empty");
    }
    
    bool FileClose(File *f) {
        if (!f) {
            return false;
    
        i64 got = FileRead(&f, buffer, (u64)fsize);
        FileClose(&f);
        if (got != fsize) {
            LOG_ERROR("read_complete_file: short read on \"{}\" (got {} of {})", filename, got, fsize);
    #endif
        bool at_eof; // last read returned 0 bytes
        bool owns;   // true when FileClose should release the handle
    } File;
        VecDeinit(&vi);
    
        FileClose(&elf);
        DefaultAllocatorDeinit(&alloc);
        return 0;
Last updated on