aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Foundation/GTMSQLite.h25
-rw-r--r--Foundation/GTMSQLite.m14
2 files changed, 38 insertions, 1 deletions
diff --git a/Foundation/GTMSQLite.h b/Foundation/GTMSQLite.h
index 0daa02c..883c903 100644
--- a/Foundation/GTMSQLite.h
+++ b/Foundation/GTMSQLite.h
@@ -122,6 +122,29 @@
//
+ (NSString *)sqliteVersionString;
+// Open a database instance on a file-based database.
+//
+// Args:
+// path: Path to the database. If it does not exist, an empty database will be created only if
+// the SQLITE_OPEN_CREATE flag is specified.
+// withCFAdditions: If true, the SQLite database will include CFString
+// based string functions and collation sequences. See
+// the class header for information on these differences
+// and performance impact.
+// utf8: If true, the path argument is interpreted as UTF-8. If false, it's interpreted as
+// UTF-16 in the native byte order.
+// flags: The SQLite flags to use when opening a DB file (e.g. SQLITE_OPEN_READWRITE). This
+// argument is ignored if utf8 is false.
+// err: Result code from SQLite. If nil is returned by this function
+// check the result code for the error. If NULL no result code is
+// reported.
+//
+- (id)initWithPath:(NSString *)path
+ withCFAdditions:(BOOL)additions
+ utf8:(BOOL)useUTF8
+ flags:(int)flags
+ errorCode:(int *)err;
+
// Create and open a database instance on a file-based database.
//
// Args:
@@ -131,6 +154,8 @@
// based string functions and collation sequences. See
// the class header for information on these differences
// and performance impact.
+// utf8: If true, the path argument is interpreted as UTF-8. If false, it's interpreted as
+// UTF-16 in the native byte order.
// err: Result code from SQLite. If nil is returned by this function
// check the result code for the error. If NULL no result code is
// reported.
diff --git a/Foundation/GTMSQLite.m b/Foundation/GTMSQLite.m
index aa5d5f5..d3add68 100644
--- a/Foundation/GTMSQLite.m
+++ b/Foundation/GTMSQLite.m
@@ -133,13 +133,14 @@ static CFLocaleRef gCurrentLocale = NULL;
- (id)initWithPath:(NSString *)path
withCFAdditions:(BOOL)additions
utf8:(BOOL)useUTF8
+ flags:(int)flags
errorCode:(int *)err {
int rc = SQLITE_INTERNAL;
if ((self = [super init])) {
path_ = [path copy];
if (useUTF8) {
- rc = sqlite3_open([path_ fileSystemRepresentation], &db_);
+ rc = sqlite3_open_v2([path_ fileSystemRepresentation], &db_, flags, NULL);
} else {
CFStringEncoding cfEncoding;
#if TARGET_RT_BIG_ENDIAN
@@ -185,6 +186,17 @@ static CFLocaleRef gCurrentLocale = NULL;
return self;
}
+- (id)initWithPath:(NSString *)path
+ withCFAdditions:(BOOL)additions
+ utf8:(BOOL)useUTF8
+ errorCode:(int *)err {
+ return [self initWithPath:path
+ withCFAdditions:additions
+ utf8:useUTF8
+ flags:SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
+ errorCode:err];
+}
+
- (id)initInMemoryWithCFAdditions:(BOOL)additions
utf8:(BOOL)useUTF8
errorCode:(int *)err {