summaryrefslogtreecommitdiffstats
path: root/src/rgw/rgw_string.cc
blob: 420db96c4f2ee483d9d19fe108b8e965195f37ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab ft=cpp

#include "rgw_string.h"
#include <fnmatch.h>

bool match_wildcards(const std::string& pattern, const std::string& input,
                     uint32_t flags)
{
  bool case_insensive = flags & MATCH_CASE_INSENSITIVE;
  uint32_t  flag = 0;

  if (case_insensive) {
    flag = FNM_CASEFOLD;
  }

  if (fnmatch(pattern.data(), input.data(), flag) == 0) {
    return true;
  } else {
    return false;
  }
}