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.
13 #include "support/lyxlib.h"
15 #include <boost/scoped_array.hpp>
26 using boost::scoped_array;
34 char * l_getcwd(char * buffer, size_t size)
37 GetCurrentDirectory(size, buffer);
40 return ::getcwd(buffer, size);
47 // Returns current working directory
48 string const lyx::support::getcwd()
50 int n = 256; // Assume path is less than 256 chars
52 scoped_array<char> tbuf(new char[n]);
54 // Safe. Hopefully all getcwds behave this way!
55 while (((err = l_getcwd(tbuf.get(), n)) == 0) && (errno == ERANGE)) {
56 // Buffer too small, double the buffersize and try again
58 tbuf.reset(new char[n]);