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"
18 #include <boost/scoped_array.hpp>
20 using boost::scoped_array;
28 char * l_getcwd(char * buffer, size_t size)
31 return ::getcwd(buffer, size);
33 return ::_getcwd2(buffer, size);
40 // Returns current working directory
41 string const lyx::support::getcwd()
43 int n = 256; // Assume path is less than 256 chars
45 scoped_array<char> tbuf(new char[n]);
47 // Safe. Hopefully all getcwds behave this way!
48 while (((err = l_getcwd(tbuf.get(), n)) == 0) && (errno == ERANGE)) {
49 // Buffer too small, double the buffersize and try again
51 tbuf.reset(new char[n]);