3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * Full author contact details are available in file CREDITS.
16 #include "support/lyxlib.h"
21 char * l_getcwd(char * buffer, size_t size)
24 return ::getcwd(buffer, size);
26 return ::_getcwd2(buffer, size);
33 // Returns current working directory
34 string const lyx::support::getcwd()
36 int n = 256; // Assume path is less than 256 chars
38 char * tbuf = new char[n];
40 // Safe. Hopefully all getcwds behave this way!
41 while (((err = l_getcwd(tbuf, n)) == 0) && (errno == ERANGE)) {
42 // Buffer too small, double the buffersize and try again
49 if (err) result = tbuf;