Skip to content

FileIsValid

Description

True if the underlying handle is valid (open).

Usage example (Cross-references)

Usage examples (Cross-references)
    static bool path_exists(const char *path) {
        File f = FileOpen(path, "rb");
        if (!FileIsValid(&f)) {
            return false;
        }
    static bool path_exists(const char *path) {
        File f = FileOpen(path, "rb");
        if (!FileIsValid(&f)) {
            return false;
        }
    static bool path_exists(const char *path) {
        File f = FileOpen(path, "rb");
        if (!FileIsValid(&f)) {
            return false;
        }
        // into a growing buffer ourselves.
        File f = FileOpen("/proc/self/maps", "rb");
        if (!FileIsValid(&f)) {
            LOG_ERROR("ProcMapsLoad: FileOpen(/proc/self/maps) failed");
            ProcMapsDeinit(out);
    }
    
    bool FileIsValid(const File *f) {
        if (!f) {
            return false;
    
    i64 FileRead(File *f, void *buf, u64 n) {
        if (!FileIsValid(f) || !buf) {
            return -1;
        }
    
    i64 FileWrite(File *f, const void *buf, u64 n) {
        if (!FileIsValid(f) || !buf) {
            return -1;
        }
    
    i64 FileSeek(File *f, i64 offset, FileWhence whence) {
        if (!FileIsValid(f)) {
            return -1;
        }
    
    bool FileFlush(File *f) {
        if (!FileIsValid(f)) {
            return false;
        }
    
        File f = FileOpen(filename, "rb");
        if (!FileIsValid(&f)) {
            return false;
        }
    
        File elf = FileOpen(argv[1], "rb");
        if (!FileIsValid(&elf)) {
            LOG_ERROR("Failed to open file for reading.");
            return 1;
Last updated on