]> git.lyx.org Git - lyx.git/blobdiff - src/support/os_unix.cpp
add generic helper class for calling functions in gui thread
[lyx.git] / src / support / os_unix.cpp
index 1808c89580badc826424ff654b29e30c0c8ea3e1..20a6316fde0519734ca5a15474722213445ca36a 100644 (file)
@@ -16,6 +16,7 @@
 #include "support/docstring.h"
 #include "support/FileName.h"
 #include "support/lstrings.h"
+#include "support/lassert.h"
 
 #include <limits.h>
 #include <stdlib.h>
@@ -30,7 +31,28 @@ namespace lyx {
 namespace support {
 namespace os {
 
-void init(int, char *[])
+namespace {
+
+int argc_ = 0;
+char ** argv_ = 0;
+
+} // namespace anon
+
+void init(int argc, char * argv[])
+{
+       argc_ = argc;
+       argv_ = argv;
+}
+
+
+string utf8_argv(int i)
+{
+       LASSERT(i < argc_, /**/);
+       return to_utf8(from_local8bit(argv_[i]));
+}
+
+
+void remove_internal_args(int, int)
 {}
 
 
@@ -130,7 +152,7 @@ string internal_path(string const & p)
 }
 
 
-string safe_internal_path(string const & p)
+string safe_internal_path(string const & p, file_access)
 {
        return p;
 }
@@ -184,12 +206,6 @@ string const & nulldev()
 }
 
 
-bool is_terminal(io_channel channel)
-{
-       return isatty(channel);
-}
-
-
 shell_type shell()
 {
        return UNIX;
@@ -281,9 +297,16 @@ bool autoOpenFile(string const & filename, auto_open_mode const mode)
 
 string real_path(string const & path)
 {
+#ifdef HAVE_DEF_PATH_MAX
        char rpath[PATH_MAX + 1];
        char * result = realpath(path.c_str(), rpath);
-       return FileName::fromFilesystemEncoding(result ? rpath : path).absFilename();
+       return FileName::fromFilesystemEncoding(result ? rpath : path).absFileName();
+#else
+       char * result = realpath(path.c_str(), NULL);
+       string ret = FileName::fromFilesystemEncoding(result ? result : path).absFileName();
+       free(result);
+       return ret;
+#endif
 }
 
 } // namespace os