File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -274,6 +274,17 @@ class Store {
274274 }
275275 }
276276
277+ /// Returns if an open store was found for the given directory
278+ /// (i.e. opened before and not yet closed).
279+ static bool isOpen (String directory) {
280+ final cStr = directory.toNativeUtf8 ();
281+ try {
282+ return C .store_is_open (cStr.cast ());
283+ } finally {
284+ malloc.free (cStr);
285+ }
286+ }
287+
277288 /// Returns a store reference you can use to create a new store instance with
278289 /// a single underlying native store. See [Store.fromReference] for more details.
279290 ByteData get reference => _reference;
Original file line number Diff line number Diff line change @@ -77,6 +77,14 @@ void main() {
7777 env.close ();
7878 });
7979
80+ test ('store is open' , () {
81+ expect (false , Store .isOpen ('testdata-basics' ));
82+ final env = TestEnv ('basics' );
83+ expect (true , Store .isOpen ('testdata-basics' ));
84+ env.close ();
85+ expect (false , Store .isOpen ('testdata-basics' ));
86+ });
87+
8088 test ('transactions' , () {
8189 final env = TestEnv ('basics' );
8290 expect (TxMode .values.length, 2 );
You can’t perform that action at this time.
0 commit comments