From f4a65d949702da27df3f49e90d67bd388fd2d429 Mon Sep 17 00:00:00 2001 From: Shuhao Wu Date: Thu, 10 Jul 2014 16:23:05 -0400 Subject: [PATCH] Added an IsDone method for backup --- backup.go | 9 +++++++++ error.go | 1 + 2 files changed, 10 insertions(+) diff --git a/backup.go b/backup.go index 2684cc0..1097543 100644 --- a/backup.go +++ b/backup.go @@ -13,6 +13,15 @@ type Backup struct { 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) { destptr := C.CString(dest) defer C.free(unsafe.Pointer(destptr)) diff --git a/error.go b/error.go index 52017bf..1634939 100644 --- a/error.go +++ b/error.go @@ -45,6 +45,7 @@ var ( ErrNotADB = ErrNo(26) /* File opened that is not a database file */ ErrNotice = ErrNo(27) /* Notifications from sqlite3_log() */ ErrWarning = ErrNo(28) /* Warnings from sqlite3_log() */ + ErrDone = ErrNo(101) ) func (err ErrNo) Error() string {