ONE - On-device Neural Engine
Loading...
Searching...
No Matches
filesystem_common.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "filesystem.h"
18
19namespace filesystem
20{
21
22std::string join(const std::string &path1, const std::string &path2)
23{
24 // TODO check path1 does not end with separator
25 // TODO check path2 does not start with separator
26 return path1 + separator() + path2;
27}
28
29std::string basename(const std::string &path)
30{
31 auto last_index = path.find_last_of(separator());
32
33 // No separator
34 if (last_index == std::string::npos)
35 return path;
36
37 // Trailing separator
38 if (last_index + separator().size() == path.size())
39 return basename(path.substr(0, last_index));
40
41 return path.substr(last_index + separator().size());
42}
43
44} // namespace filesystem
std::string join(const std::string &path1, const std::string &path2)
const std::string separator()
std::string basename(const std::string &path)
int32_t size[5]
Definition Slice.cpp:35