]> git.lyx.org Git - lyx.git/blobdiff - src/support/os_win32.cpp
Replace the text class shared ptr by good old index-into-global-list.
[lyx.git] / src / support / os_win32.cpp
index cae4849801694ecb8948f26e9fae4c62b7ad136f..329573fcbc0a9ba9b3845610c6cbf700340d24d1 100644 (file)
 
 #include "support/os.h"
 #include "support/os_win32.h"
-#include "support/lstrings.h"
+
+#include "support/debug.h"
+#include "support/FileName.h"
+#include "support/gettext.h"
 #include "support/filetools.h"
+#include "support/lstrings.h"
 #include "support/ExceptionMessage.h"
 
-#include "debug.h"
-#include "gettext.h"
-
 #include <boost/assert.hpp>
 
 #include <cstdlib>
@@ -63,9 +64,7 @@
 # endif
 #endif
 
-using std::endl;
-using std::string;
-
+using namespace std;
 
 namespace lyx {
 namespace support {
@@ -193,10 +192,8 @@ string external_path(string const & p)
 {
        string const dos_path = subst(p, "/", "\\");
 
-       LYXERR(Debug::LATEX)
-               << "<Win32 path correction> ["
-               << p << "]->>["
-               << dos_path << ']' << endl;
+       LYXERR(Debug::LATEX, "<Win32 path correction> ["
+               << p << "]->>[" << dos_path << ']');
        return dos_path;
 }
 
@@ -206,7 +203,7 @@ static string const get_long_path(string const & short_path)
        // GetLongPathName needs the path in file system encoding.
        // We can use to_local8bit, since file system encoding and the
        // local 8 bit encoding are identical on windows.
-       std::vector<char> long_path(MAX_PATH);
+       vector<char> long_path(MAX_PATH);
        DWORD result = GetLongPathName(to_local8bit(from_utf8(short_path)).c_str(),
                                       &long_path[0], long_path.size());
 
@@ -245,38 +242,19 @@ string latex_path(string const & p)
        // on windows_style_tex_paths_), but we use always forward slashes,
        // since it gets written into a .tex file.
 
-       if (!windows_style_tex_paths_ && is_absolute_path(p)) {
+       FileName path(p);
+       if (!windows_style_tex_paths_ && path.isAbsolute()) {
                string const drive = p.substr(0, 2);
                string const cygprefix = cygdrive + "/" + drive.substr(0, 1);
                string const cygpath = subst(subst(p, '\\', '/'), drive, cygprefix);
-               LYXERR(Debug::LATEX)
-                       << "<Path correction for LaTeX> ["
-                       << p << "]->>["
-                       << cygpath << ']' << endl;
+               LYXERR(Debug::LATEX, "<Path correction for LaTeX> ["
+                       << p << "]->>[" << cygpath << ']');
                return cygpath;
        }
        return subst(p, '\\', '/');
 }
 
 
-// (Claus H.) On Win32 both Unix and Win32/DOS pathnames are used.
-// Therefore an absolute path could be either a pathname starting
-// with a slash (Unix) or a pathname starting with a drive letter
-// followed by a colon. Because a colon is not valid in pathes in Unix
-// and at another location in Win32 testing just for the existance
-// of the colon in the 2nd position seems to be enough!
-bool is_absolute_path(string const & p)
-{
-       if (p.empty())
-               return false;
-
-       bool isDosPath = (p.length() > 1 && p[1] == ':');
-       bool isUnixPath = (p[0] == '/');
-
-       return isDosPath || isUnixPath;
-}
-
-
 // returns a string suitable to be passed to popen when
 // reading a pipe
 char const * popen_read_mode()