]> git.lyx.org Git - lyx.git/blobdiff - src/support/getcwd.C
fix compiler warnings about unused parameter
[lyx.git] / src / support / getcwd.C
index 2514c15af14315e46e4e5c4d79e79b75dd044295..1a0c3f213f5ea2826d53de0682603835dd847dc0 100644 (file)
 #include <config.h>
 
 #include "support/lyxlib.h"
+#include "support/os.h"
 
 #include <boost/scoped_array.hpp>
 
 #include <cerrno>
-#include <unistd.h>
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#ifdef _WIN32
+# include <windows.h>
+#endif
 
 using boost::scoped_array;
 
 using std::string;
 
 
+namespace lyx {
+namespace support {
+
 namespace {
 
 inline
 char * l_getcwd(char * buffer, size_t size)
 {
-#ifndef __EMX__
-       return ::getcwd(buffer, size);
+#ifdef _WIN32
+       GetCurrentDirectory(size, buffer);
+       return buffer;
 #else
-       return ::_getcwd2(buffer, size);
+       return ::getcwd(buffer, size);
 #endif
 }
 
@@ -38,7 +50,7 @@ char * l_getcwd(char * buffer, size_t size)
 
 
 // Returns current working directory
-string const lyx::support::getcwd()
+FileName const getcwd()
 {
        int n = 256;    // Assume path is less than 256 chars
        char * err;
@@ -54,5 +66,8 @@ string const lyx::support::getcwd()
        string result;
        if (err)
                result = tbuf.get();
-       return result;
+       return FileName(os::internal_path(to_utf8(from_filesystem8bit(result))));
 }
+
+} // namespace support
+} // namespace lyx