diff options
| author | mascarenhas <mascarenhas> | 2008-01-16 22:29:26 +0000 |
|---|---|---|
| committer | mascarenhas <mascarenhas> | 2008-01-16 22:29:26 +0000 |
| commit | 895e9daf27c7e8dcfd5c4d7f5cf1b8edf20b6e11 (patch) | |
| tree | 1c3460092c765850085a52f1fd5f9023f21e6699 /src | |
| parent | 50f17597b39ff746b5dcc45b7b4962e1483b308f (diff) | |
| download | luafilesystem-895e9daf27c7e8dcfd5c4d7f5cf1b8edf20b6e11.tar.gz luafilesystem-895e9daf27c7e8dcfd5c4d7f5cf1b8edf20b6e11.tar.bz2 luafilesystem-895e9daf27c7e8dcfd5c4d7f5cf1b8edf20b6e11.zip | |
getcwd no longer passes a buffer
Diffstat (limited to 'src')
| -rw-r--r-- | src/lfs.c | 23 |
1 files changed, 12 insertions, 11 deletions
| @@ -15,7 +15,7 @@ | |||
| 15 | ** lfs.touch (filepath [, atime [, mtime]]) | 15 | ** lfs.touch (filepath [, atime [, mtime]]) |
| 16 | ** lfs.unlock (fh) | 16 | ** lfs.unlock (fh) |
| 17 | ** | 17 | ** |
| 18 | ** $Id: lfs.c,v 1.43 2007/12/22 17:19:45 mascarenhas Exp $ | 18 | ** $Id: lfs.c,v 1.44 2008/01/16 22:29:26 mascarenhas Exp $ |
| 19 | */ | 19 | */ |
| 20 | 20 | ||
| 21 | #include <errno.h> | 21 | #include <errno.h> |
| @@ -100,16 +100,17 @@ static int change_dir (lua_State *L) { | |||
| 100 | ** and a string describing the error | 100 | ** and a string describing the error |
| 101 | */ | 101 | */ |
| 102 | static int get_dir (lua_State *L) { | 102 | static int get_dir (lua_State *L) { |
| 103 | char path[255+2]; | 103 | char *path; |
| 104 | if (getcwd(path, 255) == NULL) { | 104 | if ((path = getcwd(NULL, 0)) == NULL) { |
| 105 | lua_pushnil(L); | 105 | lua_pushnil(L) |
| 106 | lua_pushstring(L, getcwd_error); | 106 | lua_pushstring(L, getcwd_error); |
| 107 | return 2; | 107 | return 2; |
| 108 | } | 108 | } |
| 109 | else { | 109 | else { |
| 110 | lua_pushstring(L, path); | 110 | lua_pushstring(L, path); |
| 111 | return 1; | 111 | free(path); |
| 112 | } | 112 | return 1; |
| 113 | } | ||
| 113 | } | 114 | } |
| 114 | 115 | ||
| 115 | /* | 116 | /* |
