3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Ruurd A. Reitsma
7 * \author Claus Hentschel
8 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS.
12 * Various OS specific functions
17 #include "support/os.h"
18 #include "support/lstrings.h"
25 #include <sys/cygwin.h>
35 void os::init(int, char *[])
45 string::size_type common_path(string const & p1, string const & p2)
47 string::size_type i = 0;
48 string::size_type p1_len = p1.length();
49 string::size_type p2_len = p2.length();
50 while (i < p1_len && i < p2_len && uppercase(p1[i]) == uppercase(p2[i]))
52 if ((i < p1_len && i < p2_len)
53 || (i < p1_len && p1[i] != '/' && i == p2_len)
54 || (i < p2_len && p2[i] != '/' && i == p1_len))
57 --i; // here was the last match
58 while (i && p1[i] != '/')
67 bool cygwin_path_fix_ = false;
72 string external_path(string const & p)
76 // Translate from cygwin path syntax to dos path syntax
77 if (cygwin_path_fix_ && is_absolute_path(p)) {
79 cygwin_conv_to_full_win32_path(p.c_str(), dp);
80 dos_path = !dp ? "" : dp;
85 //No backslashes in LaTeX files
86 dos_path = subst(dos_path,'\\','/');
89 << "<Cygwin path correction> ["
91 << dos_path << ']' << endl;
96 string internal_path(string const & p)
98 char posix_path[PATH_MAX];
100 cygwin_conv_to_posix_path(p.c_str(), posix_path);
105 bool is_absolute_path(string const & p)
110 bool isDosPath = (p.length() > 1 && p[1] == ':');
111 bool isUnixPath = (p[0] == '/');
113 return isDosPath || isUnixPath;
117 // returns a string suitable to be passed to popen when
119 char const * popen_read_mode()
125 string const & nulldev()
127 static string const nulldev_ = "/dev/null";
138 char path_separator()
144 void cygwin_path_fix(bool use_cygwin_paths)
146 use_cygwin_paths_ = use_cygwin_paths;
150 } // namespace support