* \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.
*
#include "support/filetools.h"
-#include "support/convert.h"
#include "support/debug.h"
#include "support/environment.h"
#include "support/gettext.h"
using namespace std;
+#define USE_QPROCESS
+
namespace lyx {
namespace support {
// 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, "\\", "\\\\"), "\"", "\\\"")
+ "\"";
LYXERR(Debug::FILES, "createTmpDir: tempdir=`" << tempdir << "'\n"
<< "createTmpDir: mask=`" << mask << '\'');
- string const tmp_dir = tempdir.absFilename() + "/" + mask;
- FileName const tmpfl = FileName::tempName(tmp_dir);
- // FileName::tempName actually creates a file to make sure that it
- // stays unique. So we have to delete it before we can create
- // a dir with the same name. Note also that we are not thread
- // safe because of the gap between unlink and mkdir. (Lgb)
- tmpfl.removeFile();
+ FileName const tmpfl = FileName::tempName(tempdir, mask);
if (tmpfl.empty() || !tmpfl.createDirectory(0700)) {
- LYXERR0("LyX could not create the temporary directory '" << tmp_dir
+ LYXERR0("LyX could not create temporary directory in " << tempdir
<< "'");
return FileName();
}
FileName const createLyXTmpDir(FileName const & deflt)
{
- if (deflt.empty() || deflt.absFilename() == "/tmp")
- return createTmpDir(FileName("/tmp"), "lyx_tmpdir");
+ if (deflt.empty() || deflt == package().system_temp_dir())
+ return createTmpDir(package().system_temp_dir(), "lyx_tmpdir");
if (deflt.createDirectory(0777))
return deflt;
return createTmpDir(deflt, "lyx_tmpdir");
} else {
// some other error occured.
- return createTmpDir(FileName("/tmp"), "lyx_tmpdir");
+ return createTmpDir(package().system_temp_dir(), "lyx_tmpdir");
}
}
// 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);
string tempBase;
- FileName base_path(basePath);
- if (base_path.isAbsolute())
+ if (FileName::isAbsolute(basePath))
tempBase = basePath;
else
tempBase = addPath(FileName::getcwd().absFilename(), basePath);
{
// 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;
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;
}
}
-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)
{