]> git.lyx.org Git - lyx.git/blobdiff - src/support/filetools.cpp
add onoff support for "inset-modify changetype xxx" in include inset
[lyx.git] / src / support / filetools.cpp
index b2a11aba10c41ad5d6e9748deb3545c7b61f13ac..810694ec785c74ea8ce2fb7bcfea02bfc63790ba 100644 (file)
@@ -8,11 +8,11 @@
  * \author Ivan Schreter
  * \author Dirk Niggemann
  * \author Asger Alstrup
- * \author Lars Gullik Bjønnes
+ * \author Lars Gullik Bjønnes
  * \author Jean-Marc Lasgouttes
  * \author Angus Leeming
  * \author John Levon
- * \author Herbert Voß
+ * \author Herbert Voß
  *
  * Full author contact details are available in file CREDITS.
  *
@@ -23,7 +23,6 @@
 
 #include "support/filetools.h"
 
-#include "support/convert.h"
 #include "support/debug.h"
 #include "support/environment.h"
 #include "support/gettext.h"
@@ -51,6 +50,8 @@
 
 using namespace std;
 
+#define USE_QPROCESS
+
 namespace lyx {
 namespace support {
 
@@ -136,9 +137,13 @@ string const quoteName(string const & name, quote_style style)
                // filenames to child processes if possible. We store them in
                // a python script instead, where we don't have these
                // limitations.
+#ifndef USE_QPROCESS
                return (os::shell() == os::UNIX) ?
                        '\'' + name + '\'':
                        '"' + name + '"';
+#else
+               return '"' + name + '"';
+#endif
        case quote_python:
                return "\"" + subst(subst(name, "\\", "\\\\"), "\"", "\\\"")
                     + "\"";
@@ -375,10 +380,9 @@ string const onlyPath(string const & filename)
 // FIXME It might be nice if the code didn't simply assume that.
 FileName const makeAbsPath(string const & relPath, string const & basePath)
 {
-       FileName relative_path(relPath);
        // checks for already absolute path
-       if (relative_path.isAbsolute())
-               return relative_path;
+       if (FileName::isAbsolute(relPath))
+               return FileName(relPath);
 
        // Copies given paths
        string tempRel = os::internal_path(relPath);
@@ -387,8 +391,7 @@ FileName const makeAbsPath(string const & relPath, string const & basePath)
 
        string tempBase;
 
-       FileName base_path(basePath);
-       if (base_path.isAbsolute())
+       if (FileName::isAbsolute(basePath))
                tempBase = basePath;
        else
                tempBase = addPath(FileName::getcwd().absFilename(), basePath);
@@ -488,8 +491,7 @@ string const expandPath(string const & path)
 {
        // checks for already absolute path
        string rTemp = replaceEnvironmentPath(path);
-       FileName abs_path(rTemp);
-       if (abs_path.isAbsolute())
+       if (FileName::isAbsolute(rTemp))
                return rTemp;
 
        string temp;
@@ -526,16 +528,23 @@ string const replaceEnvironmentPath(string const & path)
        static boost::regex envvar_br_re("(.*)" + envvar_br + "(.*)");
        static boost::regex envvar_re("(.*)" + envvar + "(.*)");
        boost::smatch what;
-
-       string result = path;
+       string result;
+       string remaining = path;
        while (1) {
-               regex_match(result, what, envvar_br_re);
+               regex_match(remaining, what, envvar_br_re);
                if (!what[0].matched) {
-                       regex_match(result, what, envvar_re);
-                       if (!what[0].matched)
+                       regex_match(remaining, what, envvar_re);
+                       if (!what[0].matched) {
+                               result += remaining;
                                break;
+                       }
                }
-               result = what.str(1) + getEnv(what.str(2)) + what.str(3);
+               string env_var = getEnv(what.str(2));
+               if (!env_var.empty())
+                       result += what.str(1) + env_var;
+               else
+                       result += what.str(1) + "$" + what.str(2);
+               remaining = what.str(3);
        }
        return result;
 }
@@ -837,18 +846,6 @@ FileName const findtexfile(string const & fil, string const & /*format*/)
 }
 
 
-void removeAutosaveFile(string const & filename)
-{
-       string a = onlyPath(filename);
-       a += '#';
-       a += onlyFilename(filename);
-       a += '#';
-       FileName const autosave(a);
-       if (autosave.exists())
-               autosave.removeFile();
-}
-
-
 void readBB_lyxerrMessage(FileName const & file, bool & zipped,
        string const & message)
 {