mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Change glob() API to accept a dir parameter.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9313 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9a45f8922c
commit
5a338c3927
@ -1,3 +1,8 @@
|
||||
2004-11-26 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* FormFiledialog.C (expand_globs): changes due to the changed
|
||||
lyx::support::glob API.
|
||||
|
||||
2004-11-26 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* FileDialog.C:
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "support/globbing.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/path.h"
|
||||
#include "support/tostr.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
@ -70,7 +69,6 @@ using lyx::support::GetEnvPath;
|
||||
using lyx::support::LyXReadLink;
|
||||
using lyx::support::MakeAbsPath;
|
||||
using lyx::support::OnlyFilename;
|
||||
using lyx::support::Path;
|
||||
using lyx::support::split;
|
||||
using lyx::support::subst;
|
||||
using lyx::support::suffixIs;
|
||||
@ -99,8 +97,6 @@ namespace {
|
||||
vector<string> const expand_globs(string const & mask,
|
||||
string const & directory)
|
||||
{
|
||||
Path p(directory);
|
||||
|
||||
// Split into individual globs and then call 'glob' on each one.
|
||||
typedef boost::tokenizer<boost::char_separator<char> > Tokenizer;
|
||||
boost::char_separator<char> const separator(" ");
|
||||
@ -109,10 +105,9 @@ vector<string> const expand_globs(string const & mask,
|
||||
Tokenizer const tokens(mask, separator);
|
||||
Tokenizer::const_iterator it = tokens.begin();
|
||||
Tokenizer::const_iterator const end = tokens.end();
|
||||
for (; it != end; ++it) {
|
||||
vector<string> const tmp = lyx::support::glob(*it);
|
||||
matches.insert(matches.end(), tmp.begin(), tmp.end());
|
||||
}
|
||||
for (; it != end; ++it)
|
||||
lyx::support::glob(matches, *it, directory);
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
@ -455,7 +450,7 @@ void FileDialog::Private::SetFilters(FileFilterList const & filters)
|
||||
ss << ' ';
|
||||
ss << *it;
|
||||
}
|
||||
|
||||
|
||||
mask_ = ss.str();
|
||||
fl_set_input(file_dlg_form_->PatBox, mask_.c_str());
|
||||
}
|
||||
|
@ -1,3 +1,10 @@
|
||||
2004-11-26 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* globbing.[Ch] (glob): change API to:
|
||||
1. Append matches to the input container.
|
||||
2. Require a working_dir parameter. The function invokes chdir
|
||||
internally (through use of Path).
|
||||
|
||||
2004-11-26 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* filefilterlist.C (convert_brace_glob): moved here from
|
||||
|
@ -74,7 +74,7 @@ string const convert_brace_glob(string const & glob)
|
||||
|
||||
return pattern;
|
||||
}
|
||||
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
@ -98,7 +98,7 @@ FileFilterList::Filter::Filter(std::string const & description,
|
||||
globs_ = vector<string>(tokens.begin(), tokens.end());
|
||||
}
|
||||
|
||||
|
||||
|
||||
FileFilterList::FileFilterList(string const & qt_style_filter)
|
||||
{
|
||||
string const filter = qt_style_filter
|
||||
@ -171,7 +171,7 @@ string const FileFilterList::as_string() const
|
||||
ss << ' ';
|
||||
ss << *git;
|
||||
}
|
||||
|
||||
|
||||
if (has_description)
|
||||
ss << ')';
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "support/globbing.h"
|
||||
#include "support/path.h"
|
||||
|
||||
#include <glob.h>
|
||||
|
||||
@ -21,16 +22,22 @@ using std::vector;
|
||||
namespace lyx {
|
||||
namespace support {
|
||||
|
||||
vector<string> const glob(string const & pattern, int flags)
|
||||
void glob(vector<string> & matches,
|
||||
string const & pattern,
|
||||
string const & working_dir,
|
||||
int flags)
|
||||
{
|
||||
Path p(working_dir);
|
||||
|
||||
glob_t glob_buffer;
|
||||
glob_buffer.gl_offs = 0;
|
||||
glob(pattern.c_str(), flags, 0, &glob_buffer);
|
||||
vector<string> const matches(glob_buffer.gl_pathv,
|
||||
glob_buffer.gl_pathv +
|
||||
glob_buffer.gl_pathc);
|
||||
|
||||
matches.insert(matches.end(),
|
||||
glob_buffer.gl_pathv,
|
||||
glob_buffer.gl_pathv + glob_buffer.gl_pathc);
|
||||
|
||||
globfree(&glob_buffer);
|
||||
return matches;
|
||||
}
|
||||
|
||||
} // namespace support
|
||||
|
@ -19,11 +19,16 @@ namespace lyx {
|
||||
namespace support {
|
||||
|
||||
/** A wrapper for the Posix function 'glob'.
|
||||
* \param matches files found to match \c pattern are appended.
|
||||
* \param pattern the glob to be expanded. Eg "*.[Ch]".
|
||||
* \param working_dir the starting directory from which \c pattern
|
||||
* is to be expanded. Used only if \c pattern is a relative path.
|
||||
* \param flags flags to be passed to the system function. See 'man glob'.
|
||||
* \returns a vector of the files found to match \c pattern.
|
||||
*/
|
||||
std::vector<std::string> const glob(std::string const & pattern, int flags = 0);
|
||||
void glob(std::vector<std::string> & matches,
|
||||
std::string const & pattern,
|
||||
std::string const & working_dir,
|
||||
int flags = 0);
|
||||
|
||||
} // namespace support
|
||||
} // namespace lyx
|
||||
|
Loading…
Reference in New Issue
Block a user