#include "base/files/safe_base_name.h"
namespace base {
std::optional<SafeBaseName> SafeBaseName::Create(const FilePath& path) {
auto basename = path.BaseName();
if (!basename.IsAbsolute() && !basename.ReferencesParent() &&
!basename.EndsWithSeparator()) {
return std::make_optional(SafeBaseName(basename));
}
return std::nullopt;
}
std::optional<SafeBaseName> SafeBaseName::Create(
FilePath::StringViewType path) {
return Create(FilePath(path));
}
SafeBaseName::SafeBaseName(const FilePath& path) : path_(path) {}
bool SafeBaseName::operator==(const SafeBaseName& that) const {
return path_ == that.path_;
}
}