//returns true: dir writeable
// false: not writeable
-bool isDirWriteable(string const & path)
+bool isDirWriteable(FileName const & path)
{
lyxerr[Debug::FILES] << "isDirWriteable: " << path << endl;
- string const tmpfl = tempName(path, "lyxwritetest");
+ FileName const tmpfl(tempName(path, "lyxwritetest"));
if (tmpfl.empty())
return false;
- unlink(FileName(tmpfl));
+ unlink(tmpfl);
return true;
}
string const & fil = dit->leaf();
if (suffixIs(fil, extension))
dirlist.push_back(FileName::fromFilesystemEncoding(
- makeAbsPath(fil, encoded_dir)));
+ encoded_dir + '/' + fil));
}
return dirlist;
}
<< "createTmpDir: tempdir=`" << tempdir << "'\n"
<< "createTmpDir: mask=`" << mask << '\'' << endl;
- string const tmpfl = tempName(tempdir.absFilename(), mask);
+ FileName const tmpfl(tempName(tempdir, mask));
// lyx::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)
- unlink(FileName(tmpfl));
+ unlink(tmpfl);
- if (tmpfl.empty() || mkdir(FileName(tmpfl), 0700)) {
+ if (tmpfl.empty() || mkdir(tmpfl, 0700)) {
lyxerr << "LyX could not create the temporary directory '"
<< tmpfl << "'" << endl;
return FileName();
}
- return FileName(tmpfl);
+ return tmpfl;
}
} // namespace anon
{
if (!deflt.empty() && deflt.absFilename() != "/tmp") {
if (mkdir(deflt, 0777)) {
- if (isDirWriteable(deflt.absFilename())) {
+ if (isDirWriteable(deflt)) {
// deflt could not be created because it
// did exist already, so let's create our own
// dir inside deflt.
// Convert relative path into absolute path based on a basepath.
// If relpath is absolute, just use that.
// If basepath is empty, use CWD as base.
-string const makeAbsPath(string const & relPath, string const & basePath)
+FileName const makeAbsPath(string const & relPath, string const & basePath)
{
// checks for already absolute path
if (os::is_absolute_path(relPath))
- return relPath;
+ return FileName(relPath);
// Copies given paths
string tempRel = os::internal_path(relPath);
if (os::is_absolute_path(basePath))
tempBase = basePath;
else
- tempBase = addPath(getcwd(), basePath);
+ tempBase = addPath(getcwd().absFilename(), basePath);
// Handle /./ at the end of the path
while (suffixIs(tempBase, "/./"))
}
// returns absolute path
- return os::internal_path(tempBase);
+ return FileName(os::internal_path(tempBase));
}
rTemp = split(rTemp, temp, '/');
if (temp == ".")
- return getcwd() + '/' + rTemp;
+ return getcwd().absFilename() + '/' + rTemp;
if (temp == "~")
return package().home_dir() + '/' + rTemp;
if (temp == "..")
- return makeAbsPath(copy);
+ return makeAbsPath(copy).absFilename();
// Don't know how to handle this
return copy;
str = subst(str, home, "~");
if (str.length() <= threshold)
- return lyx::from_utf8(os::external_path(str));
+ return from_utf8(os::external_path(str));
string const prefix = ".../";
string temp;
str = head + "..." + tail;
}
- return lyx::from_utf8(os::external_path(prefix + str));
+ return from_utf8(os::external_path(prefix + str));
}
return false;
linkbuffer[nRead] = '\0'; // terminator
if (resolve)
- link = makeAbsPath(linkbuffer, onlyPath(file));
+ link = makeAbsPath(linkbuffer, onlyPath(file)).absFilename();
else
link = linkbuffer;
return true;
cmd_ret const c = runCommand(kpsecmd);
lyxerr[Debug::LATEX] << "kpse status = " << c.first << '\n'
- << "kpse result = `" << rtrim(c.second, "\n")
+ << "kpse result = `" << rtrim(c.second, "\n\r")
<< '\'' << endl;
if (c.first != -1)
- return FileName(os::internal_path(rtrim(c.second, "\n\r")));
+ return FileName(os::internal_path(rtrim(to_utf8(from_filesystem8bit(c.second)),
+ "\n\r")));
else
return FileName();
}