Skip to content

Commit

Permalink
Merge branch 'master' of http://github.com/yoshimoto/sqlite3-ruby int…
Browse files Browse the repository at this point in the history
…o yoshimoto-master
  • Loading branch information
luislavena committed Oct 30, 2010
2 parents 1a9edb8 + d4a109b commit 69ddfaf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ext/sqlite3/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,24 @@ static VALUE initialize(int argc, VALUE *argv, VALUE self)
if(Qtrue == rb_hash_aref(opts, sym_utf16)) {
status = sqlite3_open16(utf16_string_value_ptr(file), &ctx->db);
} else {
int mode;

#ifdef HAVE_RUBY_ENCODING_H
if(!UTF8_P(file)) {
file = rb_str_export_to_enc(file, rb_utf8_encoding());
}
#endif

if (Qtrue == rb_hash_aref(opts, ID2SYM(rb_intern("readonly")))) {
mode = SQLITE_OPEN_READONLY;
} else {
mode = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
}
status = sqlite3_open_v2(
StringValuePtr(file),
&ctx->db,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
NIL_P(zvfs) ? NULL : StringValuePtr(zvfs)
mode,
NIL_P(zvfs) ? NULL : StringValuePtr(zvfs)
);
}

Expand Down

0 comments on commit 69ddfaf

Please sign in to comment.