Added an IsDone method for backup

This commit is contained in:
Shuhao Wu 2014-07-10 16:23:05 -04:00
parent fd3cd65a89
commit f4a65d9497
2 changed files with 10 additions and 0 deletions

View File

@ -13,6 +13,15 @@ type Backup struct {
b *C.sqlite3_backup b *C.sqlite3_backup
} }
func IsDone(err error) bool {
sqlErr, ok := err.(Error)
if !ok {
return false
}
return sqlErr.Code == ErrDone
}
func (c *SQLiteConn) Backup(dest string, conn *SQLiteConn, src string) (*Backup, error) { func (c *SQLiteConn) Backup(dest string, conn *SQLiteConn, src string) (*Backup, error) {
destptr := C.CString(dest) destptr := C.CString(dest)
defer C.free(unsafe.Pointer(destptr)) defer C.free(unsafe.Pointer(destptr))

View File

@ -45,6 +45,7 @@ var (
ErrNotADB = ErrNo(26) /* File opened that is not a database file */ ErrNotADB = ErrNo(26) /* File opened that is not a database file */
ErrNotice = ErrNo(27) /* Notifications from sqlite3_log() */ ErrNotice = ErrNo(27) /* Notifications from sqlite3_log() */
ErrWarning = ErrNo(28) /* Warnings from sqlite3_log() */ ErrWarning = ErrNo(28) /* Warnings from sqlite3_log() */
ErrDone = ErrNo(101)
) )
func (err ErrNo) Error() string { func (err ErrNo) Error() string {