static int rockboxTruncate(sqlite3_file *pFile, sqlite_int64 size){ int fd = ((rockbox_file *)pFile)->fd; int rc; long excess = size - rb->filesize(fd); if (excess > 0) { char buf[excess]; rb->memset(buf, 0, excess); rb->lseek(fd, 0, SEEK_END); rc = rb->write(fd, buf, excess); if (rc < 0) return SQLITE_IOERR_TRUNCATE; else return SQLITE_OK; } else { rc = rb->ftruncate(((rockbox_file *)pFile)->fd, (off_t)size); if (rc) return SQLITE_IOERR_TRUNCATE; else return SQLITE_OK; } }