aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormascarenhas <mascarenhas>2008-01-16 22:29:26 +0000
committermascarenhas <mascarenhas>2008-01-16 22:29:26 +0000
commit895e9daf27c7e8dcfd5c4d7f5cf1b8edf20b6e11 (patch)
tree1c3460092c765850085a52f1fd5f9023f21e6699 /src
parent50f17597b39ff746b5dcc45b7b4962e1483b308f (diff)
downloadluafilesystem-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.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/lfs.c b/src/lfs.c
index 8142c91..1fa0a5e 100644
--- a/src/lfs.c
+++ b/src/lfs.c
@@ -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*/
102static int get_dir (lua_State *L) { 102static 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/*