#include "support/convert.h"
#include "support/debug.h"
#include "support/FileFilterList.h"
+#include "support/FileNameList.h"
#include "support/filetools.h"
#include "support/ForkedCalls.h"
#include "support/gettext.h"
using support::cmd_ret;
using support::createBufferTmpDir;
using support::FileName;
+using support::FileNameList;
using support::libFileSearch;
using support::latex_path;
using support::ltrim;
///
Undo undo_;
+
+ /// A cache for the bibfiles (including bibfiles of loaded child
+ /// documents), needed for appropriate update of natbib labels.
+ mutable FileNameList bibfilesCache_;
};
return;
}
- bibfilesCache_.clear();
+ d->bibfilesCache_.clear();
for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) {
if (it->lyxCode() == BIBTEX_CODE) {
InsetBibtex const & inset =
static_cast<InsetBibtex const &>(*it);
- vector<FileName> const bibfiles = inset.getFiles(*this);
- bibfilesCache_.insert(bibfilesCache_.end(),
+ FileNameList const bibfiles = inset.getFiles(*this);
+ d->bibfilesCache_.insert(d->bibfilesCache_.end(),
bibfiles.begin(),
bibfiles.end());
} else if (it->lyxCode() == INCLUDE_CODE) {
InsetInclude & inset =
static_cast<InsetInclude &>(*it);
inset.updateBibfilesCache(*this);
- vector<FileName> const & bibfiles =
+ FileNameList const & bibfiles =
inset.getBibfilesCache(*this);
- bibfilesCache_.insert(bibfilesCache_.end(),
+ d->bibfilesCache_.insert(d->bibfilesCache_.end(),
bibfiles.begin(),
bibfiles.end());
}
}
-vector<FileName> const & Buffer::getBibfilesCache() const
+FileNameList const & Buffer::getBibfilesCache() const
{
// if this is a child document and the parent is already loaded
// use the parent's cache instead
return tmp->getBibfilesCache();
// We update the cache when first used instead of at loading time.
- if (bibfilesCache_.empty())
+ if (d->bibfilesCache_.empty())
const_cast<Buffer *>(this)->updateBibfilesCache();
- return bibfilesCache_;
+ return d->bibfilesCache_;
}
#include "insets/InsetCode.h"
-#include "support/FileName.h"
#include "support/strfwd.h"
#include "support/types.h"
class WorkAreaManager;
}
+namespace support {
+class FileName;
+class FileNameList;
+}
+
/** The buffer object.
* This is the buffer object. It contains all the informations about
* a document loaded into LyX.
void updateBibfilesCache() const;
/// Return the cache with all bibfiles in use (including bibfiles
/// of loaded child documents).
- std::vector<support::FileName> const & getBibfilesCache() const;
+ support::FileNameList const & getBibfilesCache() const;
///
void getLabelList(std::vector<docstring> &) const;
/// The pointer never changes although *pimpl_'s contents may.
Impl * const d;
- /// A cache for the bibfiles (including bibfiles of loaded child
- /// documents), needed for appropriate update of natbib labels.
- mutable std::vector<support::FileName> bibfilesCache_;
-
frontend::GuiBufferDelegate * gui_;
};
#include "frontends/alert.h"
#include "support/debug.h"
+#include "support/FileNameList.h"
#include "support/filetools.h"
+#include "support/FileZipListDir.h"
#include "support/gettext.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
#include "support/Package.h"
#include "support/Path.h"
#include "support/Systemcall.h"
-#include "support/FileZipListDir.h"
using std::find_if;
using std::string;
using support::compare_ascii_no_case;
using support::contains;
using support::FileName;
+using support::FileNameList;
using support::getExtension;
using support::libFileSearch;
using support::libScriptSearch;
bool Converters::move(string const & fmt,
FileName const & from, FileName const & to, bool copy)
{
- if (from == to)
- return true;
bool no_errors = true;
string const path = onlyPath(from.absFilename());
string const to_base = removeExtension(to.absFilename());
string const to_extension = getExtension(to.absFilename());
- vector<FileName> const files =
- support::dirList(FileName(path), getExtension(from.absFilename()));
- for (vector<FileName>::const_iterator it = files.begin();
+ FileNameList const files = FileName(path).dirList(getExtension(from.absFilename()));
+ if (from == to)
+ return true;
+ for (FileNameList::const_iterator it = files.begin();
it != files.end(); ++it) {
string const from2 = it->absFilename();
string const file2 = onlyFilename(from2);
#include "support/ExceptionMessage.h"
#include "support/docstream.h"
+#include "support/FileNameList.h"
#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
using support::copy;
using support::DocFileName;
using support::FileName;
+using support::FileNameList;
using support::findtexfile;
using support::isValidLaTeXFilename;
using support::latex_path;
}
-vector<FileName> const InsetBibtex::getFiles(Buffer const & buffer) const
+FileNameList const InsetBibtex::getFiles(Buffer const & buffer) const
{
FileName path(buffer.filePath());
support::PathChanger p(path);
- vector<FileName> vec;
+ FileNameList vec;
string tmp;
// FIXME UNICODE
void InsetBibtex::fillWithBibKeys(Buffer const & buffer,
BiblioInfo & keylist, InsetIterator const & /*di*/) const
{
- vector<FileName> const files = getFiles(buffer);
+ FileNameList const files = getFiles(buffer);
for (vector<FileName>::const_iterator it = files.begin();
it != files.end(); ++ it) {
// This bibtex parser is a first step to parse bibtex files
#include "InsetCommand.h"
#include "BiblioInfo.h"
-#include "support/FileName.h"
+namespace lyx {
+namespace support {
+class FileNameList;
+}
-namespace lyx {
/** Used to insert BibTeX's information
*/
virtual void fillWithBibKeys(Buffer const &,
BiblioInfo &, InsetIterator const &) const;
///
- std::vector<support::FileName> const getFiles(Buffer const &) const;
+ support::FileNameList const getFiles(Buffer const &) const;
///
bool addDatabase(std::string const &);
///
#include "support/lstrings.h"
#include "support/docstream.h"
+#include "support/FileNameList.h"
#include <algorithm>
+using std::string;
+using std::vector;
namespace lyx {
using support::FileName;
+using support::FileNameList;
using support::getStringFromVector;
using support::getVectorFromString;
using support::ltrim;
using support::split;
using support::tokenPos;
-using std::string;
-using std::vector;
-
namespace {
vector<string> const init_possible_cite_commands()
BiblioInfo biblist;
- vector<FileName> const & bibfilesCache = buffer.getBibfilesCache();
+ FileNameList const & bibfilesCache = buffer.getBibfilesCache();
// compare the cached timestamps with the actual ones.
bool changed = false;
- for (vector<FileName>::const_iterator it = bibfilesCache.begin();
+ for (FileNameList::const_iterator it = bibfilesCache.begin();
it != bibfilesCache.end(); ++ it) {
FileName const f = *it;
std::time_t lastw = f.lastModified();
#include "insets/InsetListingsParams.h"
#include "support/docstream.h"
+#include "support/FileNameList.h"
#include "support/filetools.h"
#include "support/lstrings.h" // contains
#include "support/lyxalgo.h"
using support::copy;
using support::DocFileName;
using support::FileName;
+using support::FileNameList;
using support::getVectorFromString;
using support::isLyXFilename;
using support::isValidLaTeXFilename;
}
-std::vector<FileName> const &
+FileNameList const &
InsetInclude::getBibfilesCache(Buffer const & buffer) const
{
Buffer * const tmp = getChildBuffer(buffer, params());
if (tmp) {
tmp->setParent(0);
- std::vector<FileName> const & cache = tmp->getBibfilesCache();
+ FileNameList const & cache = tmp->getBibfilesCache();
tmp->setParent(&buffer);
return cache;
}
- static std::vector<FileName> const empty;
+ static FileNameList const empty;
return empty;
}
#include "Counters.h"
#include "EmbeddedFiles.h"
-#include "support/FileName.h"
-
#include <boost/scoped_ptr.hpp>
namespace lyx {
class LaTeXFeatures;
class RenderMonitoredPreview;
+namespace support {
+class FileNameList;
+}
/// for including tex/lyx files
class InsetInclude : public InsetCommand {
* Return an empty vector if the child doc is not loaded.
* \param buffer the Buffer containing this inset.
*/
- std::vector<support::FileName> const &
+ support::FileNameList const &
getBibfilesCache(Buffer const & buffer) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
#include <config.h>
#include "support/FileName.h"
+#include "support/FileNameList.h"
#include "support/debug.h"
#include "support/filetools.h"
}
+FileNameList FileName::dirList(std::string const & ext) const
+{
+ FileNameList dirlist;
+ if (!isDirectory()) {
+ LYXERR0("Directory '" << *this << "' does not exist!");
+ return dirlist;
+ }
+
+ QDir dir = d->fi.absoluteDir();
+
+ 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;
+}
+
+
FileName FileName::tempName(FileName const & dir, std::string const & mask)
{
return support::tempName(dir, mask);
namespace lyx {
namespace support {
+/// Defined in "FileNameList.h".
+class FileNameList;
+
/**
* Class for storing file names.
* The file name may be empty. If it is not empty it is an absolute path.
bool isWritable() const;
/// return true when file/directory is writable (write test file)
bool isDirWritable() const;
+ /// \return list other files in the directory having optional extension 'ext'.
+ FileNameList dirList(std::string const & ext) const;
/// copy a file
/// \return true when file/directory is writable (write test file)
bool operator==(DocFileName const &, DocFileName const &);
bool operator!=(DocFileName const &, DocFileName const &);
-
} // namespace support
} // namespace lyx
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file FileNameList.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef FILENAMELIST_H
+#define FILENAMELIST_H
+
+#include "support/FileName.h"
+
+#include <vector>
+
+namespace lyx {
+namespace support {
+
+/**
+ * Class for storing file name list.
+ * std::vector can not be forward declared in a simple way. Creating a class solves
+ * this problem.
+ */
+class FileNameList: public std::vector<FileName>
+{
+};
+
+} // namespace support
+} // namespace lyx
+
+#endif // FILENAMELIST_H
#include <utility>
#include <string>
-namespace lyx {
-namespace support {
-
-/// \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
-
/// The following functions are implemented in minizip/zipunzip.cpp, and are not in
/// the lyx::support namespace
}
-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