Commit e5e90555 authored by Sandrine Avakian's avatar Sandrine Avakian
Browse files

Merge branch 'mantis_3600'

* mantis_3600:
  VFS xTruncate implementation
parents f499b34e a356548d
......@@ -115,6 +115,28 @@ static int sqlite3bctbx_Write(sqlite3_file *p, const void *buf, int count, sqlit
return SQLITE_IOERR_WRITE;
}
/**
* TRuncates or extends a file depending on the size provided.
* @param p sqlite3_file file handle pointer.
* @param size New file size.
* @return SQLITE_OK on success, SQLITE_IOERR_TRUNCATE if an error occurred during truncate,
* SQLITE_ERROR if ther was a problem on the file descriptor.
*/
static int sqlite3bctbx_Truncate(sqlite3_file *p, sqlite_int64 size){
int rc;
sqlite3_bctbx_file_t *pFile = (sqlite3_bctbx_file_t*) p;
if (pFile->pbctbx_file){
rc = bctbx_file_truncate(pFile->pbctbx_file, size);
if( rc < 0 ) {
return SQLITE_IOERR_TRUNCATE;
}
if (rc == 0){
return SQLITE_OK;
}
}
return SQLITE_ERROR;
}
/**
* Saves the file size associated with the file handle p into the argument pSize.
......@@ -304,7 +326,7 @@ static int sqlite3bctbx_Open(sqlite3_vfs *pVfs, const char *fName, sqlite3_file
sqlite3bctbx_Close, /* xClose */
sqlite3bctbx_Read, /* xRead */
sqlite3bctbx_Write, /* xWrite */
NULL, /* xTruncate */
sqlite3bctbx_Truncate, /* xTruncate */
sqlite3bctbx_Sync,
sqlite3bctbx_FileSize,
sqlite3bctbx_nolockLock,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment