Skip to content

Commit

Permalink
Add -dbExists method to ObjSqliteDB.
Browse files Browse the repository at this point in the history
  • Loading branch information
jverkoey committed Dec 8, 2009
1 parent 0f15825 commit b3a26b5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES
@@ -1,4 +1,8 @@

Changes for December 8, 2009

- [NEW] -[ObjSqliteDB dbExists] Return TRUE if the database file exists.

Changes for November 19, 2009

- [FIXED] Closing a database, removing it, and then attempting to recreate it with the same db
Expand Down
2 changes: 2 additions & 0 deletions src/ObjSqlite/ObjSqliteDB.h
Expand Up @@ -45,6 +45,8 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
- (id) initWithPath:(NSString*)path;

- (BOOL) dbExists;

- (void) close;

@end
6 changes: 6 additions & 0 deletions src/ObjSqliteDB.m
Expand Up @@ -65,6 +65,12 @@ - (NSString*)lastErrorMessage {
}


///////////////////////////////////////////////////////////////////////////////////////////////////
- (BOOL)dbExists {
return [[NSFileManager defaultManager] fileExistsAtPath:_path];
}


///////////////////////////////////////////////////////////////////////////////////////////////////
- (ObjSqliteStatement*)createStatement {
if (nil == _createStatement && nil != _createSQL) {
Expand Down
2 changes: 2 additions & 0 deletions src/ObjSqliteTest.m
Expand Up @@ -57,10 +57,12 @@ - (void)testLoadNewDbNoCreate {
ObjSqliteDB* db = [[ObjSqliteDB alloc] initWithPath:kTestDBPath];
STAssertNotNil(db, @"The db failed to initialize.");

// This will create the sql db on the disc.
sqlite3* ObjSqliteDB = db.sqliteDB;

STAssertTrue(nil != ObjSqliteDB, @"The db failed to be created.");
STAssertTrue([[NSFileManager defaultManager] fileExistsAtPath:kTestDBPath], @"The db doesn't exist");
STAssertTrue([db dbExists], @"The db file doesn't exist.");

[db release];
db = nil;
Expand Down

0 comments on commit b3a26b5

Please sign in to comment.