]> git.lyx.org Git - lyx.git/blobdiff - src/support/chdir.C
fix compiler warnings about unused parameter
[lyx.git] / src / support / chdir.C
index f80e989036bde85aa0747653ca8110b4ad9b8959..6ac268772c18610afc0ec2ee766bb61219f863eb 100644 (file)
@@ -1,23 +1,38 @@
-#include <config.h>
+/**
+ * \file chdir.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
 
-#include <unistd.h>
+#include <config.h>
 
 #include "support/lyxlib.h"
 
-int lyx::chdir(char const * name)
-{
-#ifndef __EMX__
-       return ::chdir(name);
-#else
-       return ::_chdir2(name);
+#include "support/filename.h"
+
+
+namespace lyx {
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#ifdef _WIN32
+# include <windows.h>
 #endif
-}
 
-int lyx::chdir(string const & name)
+int support::chdir(FileName const & name)
 {
-#ifndef __EMX__
-       return ::chdir(name.c_str());
+#ifdef _WIN32
+       return SetCurrentDirectory(name.toFilesystemEncoding().c_str()) != 0 ? 0 : -1;
 #else
-       return ::_chdir2(name.c_str());
+       return ::chdir(name.toFilesystemEncoding().c_str());
 #endif
 }
+
+
+} // namespace lyx