]> git.lyx.org Git - features.git/commitdiff
move funtion with std::vector to filetools
authorPeter Kümmel <syntheticpp@gmx.net>
Sun, 2 Dec 2007 09:19:43 +0000 (09:19 +0000)
committerPeter Kümmel <syntheticpp@gmx.net>
Sun, 2 Dec 2007 09:19:43 +0000 (09:19 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21903 a592a061-630c-0410-9148-cb99ea01b6c8

src/Converter.cpp
src/support/FileName.cpp
src/support/FileName.h
src/support/filetools.cpp
src/support/filetools.h

index d927cd9c52011902c7ff509db6d2d57efb0dd76a..fc82114308018ffbb6d284c006800b2f2e52d9ab 100644 (file)
@@ -519,7 +519,8 @@ bool Converters::move(string const & fmt,
        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();
index 77b3ab7edbc76837eb98a64fec623fbf56f32755..e45c80566159f245df585dc1447c9fb7afaeab67 100644 (file)
@@ -326,37 +326,9 @@ bool FileName::createDirectory(int permission) const
 }
 
 
-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());
 }
 
 
@@ -588,7 +560,7 @@ bool FileName::isZippedFile() const
 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));
 }
 
 
index f53290159f18caf4561df4a66a6a7d8927d7275f..519ba896ace79dc276c2556b6f68202ef31cadd9 100644 (file)
@@ -15,7 +15,6 @@
 #include "support/strfwd.h"
 
 #include <ctime>
-#include <vector>
 
 
 namespace lyx {
@@ -139,12 +138,11 @@ public:
 
        /// 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:
        ///
index 1bc4c6105e7357737fd8a592f3d90409ccb44212..8b9258cfe15f8d48e78419aa618e9572df161c25 100644 (file)
@@ -934,5 +934,39 @@ int compare_timestamps(FileName const & file1, FileName const & file2)
        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
index 6e3e412ec62ac5975af3b33be50c985f42cbd4ac..dce6e6979d06d8164ca12faf4201859ad4be7985 100644 (file)
@@ -275,6 +275,9 @@ typedef std::pair<int, std::string> cmd_ret;
 
 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