/** * Writes directly to the open file given through the p argument. * Calls bctbx_file_write . * @param p sqlite3_file file handle pointer. * @param buf Buffer containing data to write * @param count Size of data to write in bytes * @param offset File offset where to write to * @return SQLITE_OK on success, SQLITE_IOERR_WRITE if an error occurred. */ static int sqlite3bctbx_Write(sqlite3_file *p, const void *buf, int count, sqlite_int64 offset){ sqlite3_bctbx_file_t *pFile = (sqlite3_bctbx_file_t*) p; int ret; if (pFile ){ ret = bctbx_file_write(pFile->pbctbx_file, buf, count, (off_t)offset); if(ret > 0 ) return SQLITE_OK; else { return SQLITE_IOERR_WRITE; } } return SQLITE_IOERR_WRITE; }
ssize_t bctbx_file_fprintf(bctbx_vfs_file_t *pFile, off_t offset, const char *fmt, ...) { char *ret = NULL; va_list args; ssize_t r = BCTBX_VFS_ERROR; size_t count = 0; va_start(args, fmt); ret = bctbx_strdup_vprintf(fmt, args); if (ret != NULL) { va_end(args); count = strlen(ret); if (offset != 0) pFile->offset = offset; r = bctbx_file_write(pFile, ret, count, pFile->offset); bctbx_free(ret); if (r > 0) pFile->offset += r; } return r; }