Mercurial > hg > octave-lyh
comparison liboctave/lo-sysdep.cc @ 10250:2d47356a7a1a
use gnulib getcwd module
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 03 Feb 2010 03:07:06 -0500 |
parents | 0522a65bcd56 |
children | 65b41bc71f09 |
comparison
equal
deleted
inserted
replaced
10249:14eba566f9f0 | 10250:2d47356a7a1a |
---|---|
53 std::string | 53 std::string |
54 octave_getcwd (void) | 54 octave_getcwd (void) |
55 { | 55 { |
56 std::string retval; | 56 std::string retval; |
57 | 57 |
58 char buf[MAXPATHLEN]; | 58 // Using the gnulib getcwd module ensures that we have a getcwd that |
59 | 59 // will allocate a buffer as large as necessary if buf and size are |
60 char *tmp = 0; | 60 // both 0. |
61 | 61 |
62 #if defined (__EMX__) | 62 char *tmp = getcwd (0, 0); |
63 tmp = _getcwd2 (buf, MAXPATHLEN); | |
64 #elif defined (HAVE_GETCWD) | |
65 tmp = getcwd (buf, MAXPATHLEN); | |
66 #elif defined (HAVE_GETWD) | |
67 tmp = getwd (buf); | |
68 #endif | |
69 | 63 |
70 if (tmp) | 64 if (tmp) |
71 retval = tmp; | 65 { |
66 retval = tmp; | |
67 free (tmp); | |
68 } | |
72 else | 69 else |
73 (*current_liboctave_error_handler) ("unable to find current directory"); | 70 (*current_liboctave_error_handler) ("unable to find current directory"); |
74 | 71 |
75 return retval; | 72 return retval; |
76 } | 73 } |