1 /* 2 * Copyright 2022 Google LLC 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 #ifndef FCP_BASE_BASE_NAME_H_ 18 #define FCP_BASE_BASE_NAME_H_ 19 20 #include <string> 21 22 #ifndef FCP_BAREMETAL 23 #include "absl/strings/string_view.h" 24 #endif 25 26 namespace fcp { 27 28 /** 29 * Returns the file base name of a path. 30 */ 31 std::string BaseName(const std::string& path); 32 33 #ifndef FCP_BAREMETAL BaseName(const char * path)34inline std::string BaseName(const char* path) { 35 return BaseName(std::string(path)); 36 } 37 BaseName(absl::string_view path)38inline std::string BaseName(absl::string_view path) { 39 return BaseName(std::string(path)); 40 } 41 #endif 42 43 } // namespace fcp 44 45 #endif // FCP_BASE_BASE_NAME_H_ 46