qcom_msm8916_64_android5.0/sources/qcom/bootable/recovery/updater/install.c
Value* ReadFileFn(const char* name, State* state, int argc, Expr* argv[]) {
    if (argc != 1) {
        return ErrorAbort(state, "%s() expects 1 arg, got %d", name, argc);
    }
    char* filename;
    if (ReadArgs(state, argv, 1, &filename) < 0) return NULL;

    Value* v = malloc(sizeof(Value));
    v->type = VAL_BLOB;

    FileContents fc;
    if (LoadFileContents(filename, &fc) != 0) {
        free(filename);
        v->size = -1;
        v->data = NULL;
        free(fc.data);
        return v;
    }

    v->size = fc.size;
    v->data = (char*)fc.data;

    free(filename);
    return v;
}
// Read a local file and return its contents (the Value* returned
// is actually a FileContents*).
Read a local file and return its contents (the Value* returned
is actually a FileContents*).
Read a local file and return its contents ( the Value * returned is actually a FileContents * ) .
Value* ReadFileFn(const char* name, State* state, int argc, Expr* argv[]) {
    if (argc != 1) {
        return ErrorAbort(state, "%s() expects 1 arg, got %d", name, argc);
    }
    char* filename;
    if (ReadArgs(state, argv, 1, &filename) < 0) return NULL;
    Value* v = malloc(sizeof(Value));
    v->type = VAL_BLOB;
    FileContents fc;
    if (LoadFileContents(filename, &fc) != 0) {
        free(filename);
        v->size = -1;
        v->data = NULL;
        free(fc.data);
        return v;
    }
    v->size = fc.size;
    v->data = (char*)fc.data;
    free(filename);
    return v;
}
Value * ReadFileFn ( const char * name , State * state , int argc , Expr * argv [ ] ) { if ( argc != 1 ) { return ErrorAbort ( state , " " , name , argc ) ; } char * filename ; if ( ReadArgs ( state , argv , 1 , & filename ) < 0 ) return NULL ; Value * v = malloc ( sizeof ( Value ) ) ; v -> type = VAL_BLOB ; FileContents fc ; if ( LoadFileContents ( filename , & fc ) != 0 ) { free ( filename ) ; v -> size = -1 ; v -> data = NULL ; free ( fc . data ) ; return v ; } v -> size = fc . size ; v -> data = ( char * ) fc . data ; free ( filename ) ; return v ; }
Read a local file and return its contents (the Value* returned
is actually a FileContents*).
Read a local file and return its contents ( the Value * returned is actually a FileContents * ) .