/// Returns a vector of all files in directory dir having extension ext.
-vector<string> const dirList(string const & dir, string const & ext)
+vector<string> const dirList(FileName const & dir, string const & ext)
{
// EXCEPTIONS FIXME. Rewrite needed when we turn on exceptions. (Lgb)
vector<string> dirlist;
- if (!(fs::exists(dir) && fs::is_directory(dir))) {
+ string const encoded_dir = dir.toFilesystemEncoding();
+ if (!(fs::exists(encoded_dir) && fs::is_directory(encoded_dir))) {
lyxerr[Debug::FILES]
<< "Directory \"" << dir
<< "\" does not exist to DirList." << endl;
extension += '.';
extension += ext;
- fs::directory_iterator dit(dir);
+ fs::directory_iterator dit(encoded_dir);
fs::directory_iterator end;
for (; dit != end; ++dit) {
string const & fil = dit->leaf();
if (suffixIs(fil, extension)) {
+ // FIXME UNICODE: We need to convert from filesystem encoding to utf8
dirlist.push_back(fil);
}
}
} // namespace anon
-bool destroyDir(string const & tmpdir)
+bool destroyDir(FileName const & tmpdir)
{
try {
- return fs::remove_all(tmpdir) > 0;
+ return fs::remove_all(tmpdir.toFilesystemEncoding()) > 0;
} catch (fs::filesystem_error const & fe){
lyxerr << "Could not delete " << tmpdir << ". (" << fe.what() << ")" << std::endl;
return false;
}
-string const findtexfile(string const & fil, string const & /*format*/)
+FileName const findtexfile(string const & fil, string const & /*format*/)
{
/* There is no problem to extend this function too use other
methods to look for files. It could be setup to look
// If the file can be found directly, we just return a
// absolute path version of it.
- if (fs::exists(fil))
- return makeAbsPath(fil);
+ FileName const absfile(makeAbsPath(fil));
+ if (fs::exists(absfile.toFilesystemEncoding()))
+ return absfile;
// No we try to find it using kpsewhich.
// It seems from the kpsewhich manual page that it is safe to use
<< "kpse result = `" << rtrim(c.second, "\n")
<< '\'' << endl;
if (c.first != -1)
- return os::internal_path(rtrim(c.second, "\n\r"));
+ return FileName(os::internal_path(rtrim(c.second, "\n\r")));
else
- return string();
+ return FileName();
}