@@ -75,22 +75,10 @@ extern "C" fn w_ok() -> Int = "moonbitlang_async_w_ok"
7575///|
7676extern "C" fn x_ok () -> Int = "moonbitlang_async_x_ok"
7777
78- ///|
79- extern "C" fn get_ENOENT () -> Int = "moonbitlang_async_get_ENOENT"
80-
81- ///|
82- let _ENOENT : Int = get_ENOENT ()
83-
84- ///|
85- extern "C" fn get_EACCES () -> Int = "moonbitlang_async_get_EACCES"
86-
87- ///|
88- let _EACCES : Int = get_EACCES ()
89-
9078///|
9179pub async fn exists (path : StringView ) -> Bool {
9280 try @event_loop .access (path , amode = f_ok (), context = "@fs.exists()" ) catch {
93- @os_error .OSError (code , ..) if code == _ENOENT => false
81+ @os_error .OSError (_ ) as err if err . is_ENOENT () => false
9482 err => raise err
9583 } noraise {
9684 _ => true
@@ -100,8 +88,8 @@ pub async fn exists(path : StringView) -> Bool {
10088///|
10189pub async fn can_read (path : StringView ) -> Bool {
10290 try @event_loop .access (path , amode = r_ok (), context = "@fs.can_read()" ) catch {
103- @os_error .OSError (code , ..) if code == _ENOENT => false
104- @os_error .OSError (code , ..) if code == _EACCES => false
91+ @os_error .OSError (_ ) as err if err . is_ENOENT () => false
92+ @os_error .OSError (_ ) as err if err . is_EACCES () => false
10593 err => raise err
10694 } noraise {
10795 _ => true
@@ -111,8 +99,8 @@ pub async fn can_read(path : StringView) -> Bool {
11199///|
112100pub async fn can_write (path : StringView ) -> Bool {
113101 try @event_loop .access (path , amode = w_ok (), context = "@fs.can_write()" ) catch {
114- @os_error .OSError (code , ..) if code == _ENOENT => false
115- @os_error .OSError (code , ..) if code == _EACCES => false
102+ @os_error .OSError (_ ) as err if err . is_ENOENT () => false
103+ @os_error .OSError (_ ) as err if err . is_EACCES () => false
116104 err => raise err
117105 } noraise {
118106 _ => true
@@ -122,8 +110,8 @@ pub async fn can_write(path : StringView) -> Bool {
122110///|
123111pub async fn can_execute (path : StringView ) -> Bool {
124112 try @event_loop .access (path , amode = x_ok (), context = "@fs.can_execute" ) catch {
125- @os_error .OSError (code , ..) if code == _ENOENT => false
126- @os_error .OSError (code , ..) if code == _EACCES => false
113+ @os_error .OSError (_ ) as err if err . is_ENOENT () => false
114+ @os_error .OSError (_ ) as err if err . is_EACCES () => false
127115 err => raise err
128116 } noraise {
129117 _ => true
0 commit comments