File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -267,6 +267,18 @@ class Store {
267
267
}
268
268
}
269
269
270
+ /// Returns if an open store (i.e. opened before and not yet closed) was found
271
+ /// for the given [databasePath] (or if null the [defaultDatabasePath] ).
272
+ static bool isOpen (String ? databasePath) {
273
+ final path = _safeDatabasePath (databasePath);
274
+ final cStr = path.toNativeUtf8 ();
275
+ try {
276
+ return C .store_is_open (cStr.cast ());
277
+ } finally {
278
+ malloc.free (cStr);
279
+ }
280
+ }
281
+
270
282
/// Returns a store reference you can use to create a new store instance with
271
283
/// a single underlying native store. See [Store.fromReference] for more details.
272
284
ByteData get reference => _reference;
Original file line number Diff line number Diff line change @@ -77,6 +77,15 @@ void main() {
77
77
env.closeAndDelete ();
78
78
});
79
79
80
+ test ('store is open' , () {
81
+ expect (false , Store .isOpen ('' ));
82
+ expect (false , Store .isOpen ('testdata-basics' ));
83
+ final env = TestEnv ('basics' );
84
+ expect (true , Store .isOpen ('testdata-basics' ));
85
+ env.closeAndDelete ();
86
+ expect (false , Store .isOpen ('testdata-basics' ));
87
+ });
88
+
80
89
test ('transactions' , () {
81
90
final env = TestEnv ('basics' );
82
91
expect (TxMode .values.length, 2 );
You can’t perform that action at this time.
0 commit comments