Beispiel #1
0
int gp_fpwrite(char *buf, uint count, int64_t offset, FILE *f)
{
#if defined(HAVE_PREAD_PWRITE) && HAVE_PREAD_PWRITE == 1
    return pwrite(fileno(f), buf, count, offset);
#else
    uint c;
    int64_t os, curroff = gp_ftell_64(f);
    if (curroff < 0) return curroff;
    
    os = gp_fseek_64(f, offset, 0);
    if (os < 0) return os;
    
    c = fwrite(buf, 1, count, f);
    if (c < 0) return c;
    
    os = gp_fseek_64(f, curroff, 0);
    if (os < 0) return os;
    
    return c;
#endif
}
Beispiel #2
0
static int64_t
clist_ftell(clist_file_ptr cf)
{
    return gp_ftell_64((FILE *) cf);
}