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>
29 using boost::scoped_array;
37 char * l_getcwd(char * buffer, size_t size)
40 GetCurrentDirectory(size, buffer);
43 return ::getcwd(buffer, size);
50 // Returns current working directory
51 string const lyx::support::getcwd()
53 int n = 256; // Assume path is less than 256 chars
55 scoped_array<char> tbuf(new char[n]);
57 // Safe. Hopefully all getcwds behave this way!
58 while (((err = l_getcwd(tbuf.get(), n)) == 0) && (errno == ERANGE)) {
59 // Buffer too small, double the buffersize and try again
61 tbuf.reset(new char[n]);