grpc
third_party
abseil-cpp
absl
flags
internal
abseil-cpp/absl/flags/internal/path_util.h
Go to the documentation of this file.
1
//
2
// Copyright 2019 The Abseil Authors.
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
// https://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
#ifndef ABSL_FLAGS_INTERNAL_PATH_UTIL_H_
17
#define ABSL_FLAGS_INTERNAL_PATH_UTIL_H_
18
19
#include "absl/base/config.h"
20
#include "absl/strings/string_view.h"
21
22
namespace
absl
{
23
ABSL_NAMESPACE_BEGIN
24
namespace
flags_internal {
25
26
// A portable interface that returns the basename of the filename passed as an
27
// argument. It is similar to basename(3)
28
// <https://linux.die.net/man/3/basename>.
29
// For example:
30
// flags_internal::Basename("a/b/prog/file.cc")
31
// returns "file.cc"
32
// flags_internal::Basename("file.cc")
33
// returns "file.cc"
34
inline
absl::string_view
Basename
(
absl::string_view
filename
) {
35
auto
last_slash_pos =
filename
.
find_last_of
(
"/\\"
);
36
37
return
last_slash_pos ==
absl::string_view::npos
38
?
filename
39
:
filename
.substr(last_slash_pos + 1);
40
}
41
42
// A portable interface that returns the directory name of the filename
43
// passed as an argument, including the trailing slash.
44
// Returns the empty string if a slash is not found in the input file name.
45
// For example:
46
// flags_internal::Package("a/b/prog/file.cc")
47
// returns "a/b/prog/"
48
// flags_internal::Package("file.cc")
49
// returns ""
50
inline
absl::string_view
Package
(
absl::string_view
filename
) {
51
auto
last_slash_pos =
filename
.
find_last_of
(
"/\\"
);
52
53
return
last_slash_pos ==
absl::string_view::npos
54
?
absl::string_view
()
55
:
filename
.substr(0, last_slash_pos + 1);
56
}
57
58
}
// namespace flags_internal
59
ABSL_NAMESPACE_END
60
}
// namespace absl
61
62
#endif // ABSL_FLAGS_INTERNAL_PATH_UTIL_H_
filename
const char * filename
Definition:
bloaty/third_party/zlib/contrib/minizip/ioapi.h:135
absl::string_view
Definition:
abseil-cpp/absl/strings/string_view.h:167
ABSL_NAMESPACE_END
#define ABSL_NAMESPACE_END
Definition:
third_party/abseil-cpp/absl/base/config.h:171
ABSL_NAMESPACE_BEGIN
#define ABSL_NAMESPACE_BEGIN
Definition:
third_party/abseil-cpp/absl/base/config.h:170
absl::flags_internal::Basename
absl::string_view Basename(absl::string_view filename)
Definition:
abseil-cpp/absl/flags/internal/path_util.h:34
absl::flags_internal::Package
absl::string_view Package(absl::string_view filename)
Definition:
abseil-cpp/absl/flags/internal/path_util.h:50
string_view
absl::string_view string_view
Definition:
attr.cc:22
absl::string_view::find_last_of
size_type find_last_of(string_view s, size_type pos=npos) const noexcept
Definition:
abseil-cpp/absl/strings/string_view.cc:165
absl
Definition:
abseil-cpp/absl/algorithm/algorithm.h:31
absl::string_view::npos
static constexpr size_type npos
Definition:
abseil-cpp/absl/strings/string_view.h:182
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:41