]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_multipart_meta_filter.cc
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rgw / rgw_multipart_meta_filter.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
3
4 #include "svc_tier_rados.h"
5
6 using namespace std;
7
8 const std::string MP_META_SUFFIX = ".meta";
9
10 bool MultipartMetaFilter::filter(const string& name, string& key) {
11 // the length of the suffix so we can skip past it
12 static const size_t MP_META_SUFFIX_LEN = MP_META_SUFFIX.length();
13
14 size_t len = name.size();
15
16 // make sure there's room for suffix plus at least one more
17 // character
18 if (len <= MP_META_SUFFIX_LEN)
19 return false;
20
21 size_t pos = name.find(MP_META_SUFFIX, len - MP_META_SUFFIX_LEN);
22 if (pos == string::npos)
23 return false;
24
25 pos = name.rfind('.', pos - 1);
26 if (pos == string::npos)
27 return false;
28
29 key = name.substr(0, pos);
30
31 return true;
32 }