]> git.lyx.org Git - lyx.git/blobdiff - src/support/os_unix.cpp
an example for the sweave module, prepared by Gregor Gorjanc
[lyx.git] / src / support / os_unix.cpp
index 6ca1094fdd44118e65601251de86e085b2327848..eb8c1dfa4e3440433002c6ad76538ddd7b4687cd 100644 (file)
@@ -17,7 +17,8 @@
 #include "support/FileName.h"
 #include "support/lstrings.h"
 
-#include <sys/stat.h>
+#include <limits.h>
+#include <stdlib.h>
 
 #ifdef __APPLE__
 #include <Carbon/Carbon.h>
@@ -129,6 +130,12 @@ string const & nulldev()
 }
 
 
+bool is_terminal(io_channel channel)
+{
+       return isatty(channel);
+}
+
+
 shell_type shell()
 {
        return UNIX;
@@ -218,18 +225,11 @@ bool autoOpenFile(string const & filename, auto_open_mode const mode)
 }
 
 
-bool isSameFile(string const & fileone, string const & filetwo)
+string real_path(string const & path)
 {
-       struct stat st1;
-       struct stat st2;
-
-       if (::stat(fileone.c_str(), &st1) == 0
-           && ::stat(filetwo.c_str(), &st2) == 0) {
-               return st1.st_ino == st2.st_ino && st1.st_dev == st2.st_dev;
-       }
-
-       // One or both files cannot be accessed.
-       return false;
+       char rpath[PATH_MAX + 1];
+       char * result = realpath(path.c_str(), rpath);
+       return FileName::fromFilesystemEncoding(result ? rpath : path).absFilename();
 }
 
 } // namespace os