File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -266,6 +266,17 @@ class Store {
266266 }
267267 }
268268
269+ /// Returns if an open store was found for the given directory
270+ /// (i.e. opened before and not yet closed).
271+ static bool isOpen (String directory) {
272+ final cStr = directory.toNativeUtf8 ();
273+ try {
274+ return C .store_is_open (cStr.cast ());
275+ } finally {
276+ malloc.free (cStr);
277+ }
278+ }
279+
269280 /// Returns a store reference you can use to create a new store instance with
270281 /// a single underlying native store. See [Store.fromReference] for more details.
271282 ByteData get reference => _reference;
Original file line number Diff line number Diff line change @@ -77,6 +77,15 @@ void main() {
7777 env.close ();
7878 });
7979
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.close ();
86+ expect (false , Store .isOpen ('testdata-basics' ));
87+ });
88+
8089 test ('transactions' , () {
8190 final env = TestEnv ('basics' );
8291 expect (TxMode .values.length, 2 );
You can’t perform that action at this time.
0 commit comments