File tree 2 files changed +18
-4
lines changed
2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -81,9 +81,18 @@ void processCwd(WrenVM* vm)
81
81
{
82
82
wrenEnsureSlots (vm , 1 );
83
83
84
- char buffer [WREN_PATH_MAX * 4 ];
85
- size_t length = sizeof (buffer );
86
- if (uv_cwd (buffer , & length ) != 0 )
84
+ char _buffer [PATH_MAX * 2 + 1 ];
85
+ char * buffer = _buffer ;
86
+ size_t length = sizeof (_buffer );
87
+ int result = uv_cwd (buffer , & length );
88
+
89
+ if (result == UV_ENOBUFS )
90
+ {
91
+ buffer = (char * )malloc (length );
92
+ result = uv_cwd (buffer , & length );
93
+ }
94
+
95
+ if (result != 0 )
87
96
{
88
97
wrenSetSlotString (vm , 0 , "Cannot get current working directory." );
89
98
wrenAbortFiber (vm , 0 );
Original file line number Diff line number Diff line change 1
1
#ifndef process_h
2
2
#define process_h
3
3
4
+ #include "limits.h"
4
5
#include "wren.h"
5
6
6
- #define WREN_PATH_MAX 4096
7
+ #ifdef PATH_MAX
8
+ # define WREN_PATH_MAX PATH_MAX
9
+ #else
10
+ # define WREN_PATH_MAX 4096
11
+ #endif
7
12
8
13
// Stores the command line arguments passed to the CLI.
9
14
void osSetArguments (int argc , const char * argv []);
You can’t perform that action at this time.
0 commit comments