| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2007 August 22 | 2 ** 2007 August 22 |
| 3 ** | 3 ** |
| 4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
| 5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
| 6 ** | 6 ** |
| 7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
| 8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
| 9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
| 10 ** | 10 ** |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 int rc = SQLITE_OK; | 52 int rc = SQLITE_OK; |
| 53 if( !p->pReal ){ | 53 if( !p->pReal ){ |
| 54 sqlite3_file *pReal = (sqlite3_file *)&p[1]; | 54 sqlite3_file *pReal = (sqlite3_file *)&p[1]; |
| 55 rc = sqlite3OsOpen(p->pVfs, p->zJournal, pReal, p->flags, 0); | 55 rc = sqlite3OsOpen(p->pVfs, p->zJournal, pReal, p->flags, 0); |
| 56 if( rc==SQLITE_OK ){ | 56 if( rc==SQLITE_OK ){ |
| 57 p->pReal = pReal; | 57 p->pReal = pReal; |
| 58 if( p->iSize>0 ){ | 58 if( p->iSize>0 ){ |
| 59 assert(p->iSize<=p->nBuf); | 59 assert(p->iSize<=p->nBuf); |
| 60 rc = sqlite3OsWrite(p->pReal, p->zBuf, p->iSize, 0); | 60 rc = sqlite3OsWrite(p->pReal, p->zBuf, p->iSize, 0); |
| 61 } | 61 } |
| 62 if( rc!=SQLITE_OK ){ |
| 63 /* If an error occurred while writing to the file, close it before |
| 64 ** returning. This way, SQLite uses the in-memory journal data to |
| 65 ** roll back changes made to the internal page-cache before this |
| 66 ** function was called. */ |
| 67 sqlite3OsClose(pReal); |
| 68 p->pReal = 0; |
| 69 } |
| 62 } | 70 } |
| 63 } | 71 } |
| 64 return rc; | 72 return rc; |
| 65 } | 73 } |
| 66 | 74 |
| 67 /* | 75 /* |
| 68 ** Close the file. | 76 ** Close the file. |
| 69 */ | 77 */ |
| 70 static int jrnlClose(sqlite3_file *pJfd){ | 78 static int jrnlClose(sqlite3_file *pJfd){ |
| 71 JournalFile *p = (JournalFile *)pJfd; | 79 JournalFile *p = (JournalFile *)pJfd; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 ** If the argument p points to a JournalFile structure, and the underlying | 229 ** If the argument p points to a JournalFile structure, and the underlying |
| 222 ** file has not yet been created, create it now. | 230 ** file has not yet been created, create it now. |
| 223 */ | 231 */ |
| 224 int sqlite3JournalCreate(sqlite3_file *p){ | 232 int sqlite3JournalCreate(sqlite3_file *p){ |
| 225 if( p->pMethods!=&JournalFileMethods ){ | 233 if( p->pMethods!=&JournalFileMethods ){ |
| 226 return SQLITE_OK; | 234 return SQLITE_OK; |
| 227 } | 235 } |
| 228 return createFile((JournalFile *)p); | 236 return createFile((JournalFile *)p); |
| 229 } | 237 } |
| 230 | 238 |
| 239 /* |
| 240 ** The file-handle passed as the only argument is guaranteed to be an open |
| 241 ** file. It may or may not be of class JournalFile. If the file is a |
| 242 ** JournalFile, and the underlying file on disk has not yet been opened, |
| 243 ** return 0. Otherwise, return 1. |
| 244 */ |
| 245 int sqlite3JournalExists(sqlite3_file *p){ |
| 246 return (p->pMethods!=&JournalFileMethods || ((JournalFile *)p)->pReal!=0); |
| 247 } |
| 248 |
| 231 /* | 249 /* |
| 232 ** Return the number of bytes required to store a JournalFile that uses vfs | 250 ** Return the number of bytes required to store a JournalFile that uses vfs |
| 233 ** pVfs to create the underlying on-disk files. | 251 ** pVfs to create the underlying on-disk files. |
| 234 */ | 252 */ |
| 235 int sqlite3JournalSize(sqlite3_vfs *pVfs){ | 253 int sqlite3JournalSize(sqlite3_vfs *pVfs){ |
| 236 return (pVfs->szOsFile+sizeof(JournalFile)); | 254 return (pVfs->szOsFile+sizeof(JournalFile)); |
| 237 } | 255 } |
| 238 #endif | 256 #endif |
| OLD | NEW |