File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change 13
13
#ifdef _WIN32
14
14
#include < direct.h>
15
15
#endif
16
+ #ifndef _WIN32
17
+ #include < unistd.h>
18
+ #endif
16
19
#include < fcntl.h>
17
20
#include < filesystem>
18
21
#include < map>
@@ -659,26 +662,20 @@ int fs_exists(lua_State* L)
659
662
auto * req = new uv_fs_t ();
660
663
req->data = new ResumeToken (getResumeToken (L));
661
664
662
- int err = uv_fs_stat (
665
+ int err = uv_fs_access (
663
666
uv_default_loop (),
664
667
req,
665
668
path,
669
+ F_OK,
666
670
[](uv_fs_t * req)
667
671
{
668
672
auto * request_state = static_cast <ResumeToken*>(req->data );
669
673
670
674
request_state->get ()->complete (
671
675
[req](lua_State* L)
672
676
{
673
- if (req->result == UV_ENOENT)
674
- {
675
- lua_pushboolean (L, false ); // does not exist
676
- }
677
- else
678
- {
679
- lua_pushboolean (L, true );
680
- }
681
-
677
+ lua_pushboolean (L, req->result == 0 );
678
+
682
679
uv_fs_req_cleanup (req);
683
680
684
681
delete req;
You can’t perform that action at this time.
0 commit comments