Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
bc854250
Commit
bc854250
authored
Jun 22, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/Glob: use fnmatch() if available
parent
a6aea4ba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
configure.ac
configure.ac
+1
-0
Glob.hxx
src/fs/Glob.hxx
+21
-1
No files found.
configure.ac
View file @
bc854250
...
...
@@ -225,6 +225,7 @@ if test x$host_is_linux = xyes; then
fi
AC_CHECK_FUNCS(getpwnam_r getpwuid_r)
AC_CHECK_FUNCS(fnmatch)
AC_CHECK_FUNCS(strndup)
if test x$host_is_linux = xyes; then
...
...
src/fs/Glob.hxx
View file @
bc854250
...
...
@@ -22,7 +22,11 @@
#include "check.h"
#ifdef HAVE_GLIB
#ifdef HAVE_FNMATCH
#define HAVE_CLASS_GLOB
#include <string>
#include <fnmatch.h>
#elif defined(HAVE_GLIB)
#define HAVE_CLASS_GLOB
#include <glib.h>
#endif
...
...
@@ -35,9 +39,20 @@
* (asterisk and question mark).
*/
class
Glob
{
#ifdef HAVE_FNMATCH
std
::
string
pattern
;
#else
GPatternSpec
*
pattern
;
#endif
public
:
#ifdef HAVE_FNMATCH
explicit
Glob
(
const
char
*
_pattern
)
:
pattern
(
_pattern
)
{}
Glob
(
Glob
&&
other
)
:
pattern
(
std
::
move
(
other
.
pattern
))
{}
#else
explicit
Glob
(
const
char
*
_pattern
)
:
pattern
(
g_pattern_spec_new
(
_pattern
))
{}
...
...
@@ -49,10 +64,15 @@ public:
~
Glob
()
{
g_pattern_spec_free
(
pattern
);
}
#endif
gcc_pure
bool
Check
(
const
char
*
name_fs
)
const
{
#ifdef HAVE_FNMATCH
return
fnmatch
(
pattern
.
c_str
(),
name_fs
,
0
)
==
0
;
#else
return
g_pattern_match_string
(
pattern
,
name_fs
);
#endif
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment