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"
14 #include "support/os.h"
16 #include <boost/scoped_array.hpp>
28 using boost::scoped_array;
39 char * l_getcwd(char * buffer, size_t size)
42 GetCurrentDirectory(size, buffer);
45 return ::getcwd(buffer, size);
52 // Returns current working directory
53 FileName const getcwd()
55 int n = 256; // Assume path is less than 256 chars
57 scoped_array<char> tbuf(new char[n]);
59 // Safe. Hopefully all getcwds behave this way!
60 while (((err = l_getcwd(tbuf.get(), n)) == 0) && (errno == ERANGE)) {
61 // Buffer too small, double the buffersize and try again
63 tbuf.reset(new char[n]);
69 return FileName(os::internal_path(to_utf8(from_filesystem8bit(result))));
72 } // namespace support