string const to_base = removeExtension(to.absFilename());
string const to_extension = getExtension(to.absFilename());
- vector<FileName> const files = FileName(path).dirList(getExtension(from.absFilename()));
+ vector<FileName> const files =
+ support::dirList(FileName(path), getExtension(from.absFilename()));
for (vector<FileName>::const_iterator it = files.begin();
it != files.end(); ++it) {
string const from2 = it->absFilename();
}
-std::vector<FileName> FileName::dirList(std::string const & ext)
+docstring const FileName::absoluteFilePath() const
{
- std::vector<FileName> dirlist;
- if (!isDirectory()) {
- LYXERR0("Directory '" << *this << "' does not exist!");
- return dirlist;
- }
-
- QDir dir(d->fi.absoluteFilePath());
-
- if (!ext.empty()) {
- QString filter;
- switch (ext[0]) {
- case '.': filter = "*" + toqstr(ext); break;
- case '*': filter = toqstr(ext); break;
- default: filter = "*." + toqstr(ext);
- }
- dir.setNameFilters(QStringList(filter));
- LYXERR(Debug::FILES, "filtering on extension "
- << fromqstr(filter) << " is requested.");
- }
-
- QFileInfoList list = dir.entryInfoList();
- for (int i = 0; i != list.size(); ++i) {
- FileName fi;
- fi.d->fi = list.at(i);
- dirlist.push_back(fi);
- LYXERR(Debug::FILES, "found file " << fi);
- }
-
- return dirlist;
+ return qstring_to_ucs4(d->fi.absoluteFilePath());
}
docstring const FileName::relPath(string const & path) const
{
// FIXME UNICODE
- return makeRelPath(qstring_to_ucs4(d->fi.absoluteFilePath()), from_utf8(path));
+ return makeRelPath(absoluteFilePath(), from_utf8(path));
}
#include "support/strfwd.h"
#include <ctime>
-#include <vector>
namespace lyx {
/// change to a directory, return success
bool chdir() const;
-
- /// \return list other files in the directory having optional extension 'ext'.
- std::vector<FileName> dirList(std::string const & ext = empty_string());
/// \param buffer_path if empty, uses `pwd`
docstring const relPath(std::string const & path) const;
+
+ docstring const absoluteFilePath() const;
private:
///
return cmp;
}
+
+std::vector<FileName> dirList(FileName const & filename, std::string const & ext)
+{
+ std::vector<FileName> dirlist;
+ if (!filename.isDirectory()) {
+ LYXERR0("Directory '" << filename << "' does not exist!");
+ return dirlist;
+ }
+
+ QDir dir(toqstr(filename.absoluteFilePath()));
+
+ if (!ext.empty()) {
+ QString filter;
+ switch (ext[0]) {
+ case '.': filter = "*" + toqstr(ext); break;
+ case '*': filter = toqstr(ext); break;
+ default: filter = "*." + toqstr(ext);
+ }
+ dir.setNameFilters(QStringList(filter));
+ LYXERR(Debug::FILES, "filtering on extension "
+ << fromqstr(filter) << " is requested.");
+ }
+
+ QFileInfoList list = dir.entryInfoList();
+ for (int i = 0; i != list.size(); ++i) {
+ FileName fi(fromqstr(list.at(i).absoluteFilePath()));
+ dirlist.push_back(fi);
+ LYXERR(Debug::FILES, "found file " << fi);
+ }
+
+ return dirlist;
+}
+
+
} //namespace support
} // namespace lyx
cmd_ret const runCommand(std::string const & cmd);
+/// \return list other files in the directory having optional extension 'ext'.
+std::vector<FileName> dirList(FileName const & filename, std::string const & ext);
+
} // namespace support
} // namespace lyx