* \author unknown
* \author John Levon
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
-#include <unistd.h>
-#include <cstdlib>
-#include <pwd.h>
-#include <grp.h>
-#include <map>
-#include <algorithm>
+#include "FormFiledialog.h"
+#include "forms/form_filedialog.h"
-using std::map;
-using std::max;
-using std::sort;
+#include "forms_gettext.h"
+#include "xforms_helpers.h"
+
+#include "frontends/Dialogs.h"
-#include "frontends/Alert.h"
#include "support/FileInfo.h"
#include "support/lyxlib.h"
#include "support/lstrings.h"
-#include "gettext.h"
-#include "frontends/Dialogs.h"
-#include "forms_gettext.h"
-#include "xforms_helpers.h"
+#include "support/tostr.h"
+#include "support/filetools.h"
+
+#include "lyx_forms.h"
#include <boost/bind.hpp>
+#include <boost/regex.hpp>
+
+#include <algorithm>
+#include <map>
+#include <grp.h>
+#include <pwd.h>
//#ifdef HAVE_ERRNO_H
//#include <cerrno>
# endif
#endif
+using lyx::support::AbsolutePath;
+using lyx::support::AddName;
+using lyx::support::ExpandPath;
+using lyx::support::FileInfo;
+using lyx::support::getcwd;
+using lyx::support::GetEnvPath;
+using lyx::support::LyXReadLink;
+using lyx::support::MakeAbsPath;
+using lyx::support::OnlyFilename;
+using lyx::support::split;
+using lyx::support::subst;
+using lyx::support::suffixIs;
+using lyx::support::trim;
+
+using std::max;
+using std::sort;
+using std::string;
+using std::map;
-#include "support/filetools.h"
-#include "FormFiledialog.h"
-#include "forms/form_filedialog.h"
-#include FORMS_H_LOCATION
namespace {
void UserCache::add(uid_t ID) const
{
struct passwd const * entry = getpwuid(ID);
- users[ID] = entry ? entry->pw_name : tostr(ID);
+ users[ID] = entry ? entry->pw_name : tostr(int(ID));
}
void GroupCache::add(gid_t ID) const
{
struct group const * entry = getgrgid(ID);
- groups[ID] = entry ? entry->gr_name : tostr(ID);
+ groups[ID] = entry ? entry->gr_name : tostr(int(ID));
}
// local instances
int FileDialog::Private::minh_ = 0;
+namespace {
+
+boost::regex getRegex(string const & pat)
+{
+ // We massage the pattern a bit so that the usual
+ // shell pattern we all are used to will work.
+ // One nice thing about using a real regex is that
+ // things like "*.*[^~]" will work also.
+ // build the regex string.
+ string pattern = subst(pat, ".", "\\.");
+ pattern = subst(pattern, "*", ".*");
+
+ boost::regex reg(pattern);
+ return reg;
+}
+
+
+bool globMatch(string const & a, boost::regex const & reg)
+{
+ return boost::regex_match(a, reg);
+}
+
+} // namespace anon
+
+
// Reread: updates dialog list to match class directory
void FileDialog::Private::Reread()
{
Alert::err_alert(_("Warning! Couldn't open directory."),
directory_);
#endif
- directory_ = lyx::getcwd();
+ directory_ = getcwd();
dir = ::opendir(directory_.c_str());
}
}
// Parses all entries of the given subdirectory
+ boost::regex reg = getRegex(mask_);
+
time_t curTime = time(0);
rewinddir(dir);
while (dirent * entry = readdir(dir)) {
|| fileInfo.isChar()
|| fileInfo.isBlock()
|| fileInfo.isFifo()) {
- if (!regexMatch(fname, mask_))
+ if (!globMatch(fname, reg))
continue;
} else if (!(isDir = fileInfo.isDir()))
continue;
{
string tmp;
if (path.empty())
- tmp = lyx::getcwd();
+ tmp = getcwd();
else
tmp = MakeAbsPath(ExpandPath(path), directory_);