blob: 8d6c35a33abf76f6a55c2cb1b883d293753eeade [file] [log] [blame]
Corina633099b2020-06-17 21:55:33 +01001// Copyright (C) 2019 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#define LOG_TAG "FuseUtils"
16
17#include "include/libfuse_jni/FuseUtils.h"
18
19#include <string>
20#include <vector>
21
22using std::string;
23
24namespace mediaprovider {
25namespace fuse {
26
27bool containsMount(const string& path, const string& userid) {
28 const string& prefix = "/storage/emulated/" + userid;
29 std::vector<string> suffixes = {"/Android", "/Android/data", "/Android/obb"};
30
31 if (path.find(prefix) != 0) {
32 return false;
33 }
34
35 const string& path_suffix = path.substr(prefix.length());
36 return std::find(suffixes.begin(), suffixes.end(), path_suffix) != suffixes.end();
37}
38
39} // namespace fuse
40} // namespace mediaprovider