diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/base/files/file_path.cc | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/base/files/file_path.cc')
-rw-r--r-- | chromium/base/files/file_path.cc | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/chromium/base/files/file_path.cc b/chromium/base/files/file_path.cc index f1a4b0a9bf6..56c02d2bfc7 100644 --- a/chromium/base/files/file_path.cc +++ b/chromium/base/files/file_path.cc @@ -40,20 +40,6 @@ const char* const kCommonDoubleExtensionSuffixes[] = {"gz", "xz", "bz2", "z", "bz"}; const char* const kCommonDoubleExtensions[] = { "user.js" }; -// Compatibility shim for cross-platform code that passes a StringPieceType to a -// string utility function. Most of these functions are only implemented for -// base::StringPiece and base::StringPiece16, which is why base::WStringPieces -// need to be converted. -#if defined(OS_WIN) -StringPiece16 AsCommonStringPiece(WStringPiece str) { - return AsStringPiece16(str); -} -#else -StringPiece AsCommonStringPiece(StringPiece str) { - return str; -} -#endif - const FilePath::CharType kStringTerminator = FILE_PATH_LITERAL('\0'); // If this FilePath contains a drive letter specification, returns the @@ -84,8 +70,7 @@ bool EqualDriveLetterCaseInsensitive(StringPieceType a, StringPieceType b) { StringPieceType a_letter(a.substr(0, a_letter_pos + 1)); StringPieceType b_letter(b.substr(0, b_letter_pos + 1)); - if (!StartsWith(AsCommonStringPiece(a_letter), AsCommonStringPiece(b_letter), - CompareCase::INSENSITIVE_ASCII)) + if (!StartsWith(a_letter, b_letter, CompareCase::INSENSITIVE_ASCII)) return false; StringPieceType a_rest(a.substr(a_letter_pos + 1)); @@ -156,13 +141,13 @@ StringType::size_type ExtensionSeparatorPosition(const StringType& path) { for (auto* i : kCommonDoubleExtensions) { StringType extension(path, penultimate_dot + 1); - if (LowerCaseEqualsASCII(AsCommonStringPiece(extension), i)) + if (LowerCaseEqualsASCII(extension, i)) return penultimate_dot; } StringType extension(path, last_dot + 1); for (auto* i : kCommonDoubleExtensionSuffixes) { - if (LowerCaseEqualsASCII(AsCommonStringPiece(extension), i)) { + if (LowerCaseEqualsASCII(extension, i)) { if ((last_dot - penultimate_dot) <= 5U && (last_dot - penultimate_dot) > 1U) { return penultimate_dot; @@ -201,7 +186,7 @@ FilePath::~FilePath() = default; FilePath& FilePath::operator=(const FilePath& that) = default; -FilePath& FilePath::operator=(FilePath&& that) = default; +FilePath& FilePath::operator=(FilePath&& that) noexcept = default; bool FilePath::operator==(const FilePath& that) const { #if defined(FILE_PATH_USES_DRIVE_LETTERS) @@ -295,9 +280,7 @@ bool FilePath::AppendRelativePath(const FilePath& child, // never case sensitive. if ((FindDriveLetter(*parent_comp) != StringType::npos) && (FindDriveLetter(*child_comp) != StringType::npos)) { - if (!StartsWith(AsCommonStringPiece(*parent_comp), - AsCommonStringPiece(*child_comp), - CompareCase::INSENSITIVE_ASCII)) + if (!StartsWith(*parent_comp, *child_comp, CompareCase::INSENSITIVE_ASCII)) return false; ++parent_comp; ++child_comp; @@ -613,21 +596,19 @@ bool FilePath::ReferencesParent() const { #if defined(OS_WIN) string16 FilePath::LossyDisplayName() const { - return string16(as_u16cstr(path_.data()), path_.size()); + return AsString16(path_); } std::string FilePath::MaybeAsASCII() const { - if (base::IsStringASCII(AsCommonStringPiece(path_))) - return UTF16ToASCII(AsCommonStringPiece(path_)); - return std::string(); + return base::IsStringASCII(path_) ? WideToASCII(path_) : std::string(); } std::string FilePath::AsUTF8Unsafe() const { - return UTF16ToUTF8(AsCommonStringPiece(value())); + return WideToUTF8(value()); } string16 FilePath::AsUTF16Unsafe() const { - return string16(AsCommonStringPiece(value())); + return WideToUTF16(value()); } // static @@ -637,7 +618,7 @@ FilePath FilePath::FromUTF8Unsafe(StringPiece utf8) { // static FilePath FilePath::FromUTF16Unsafe(StringPiece16 utf16) { - return FilePath(WStringPiece(as_wcstr(utf16.data()), utf16.size())); + return FilePath(AsWStringPiece(utf16)); } #elif defined(OS_POSIX) || defined(OS_FUCHSIA) @@ -693,7 +674,7 @@ FilePath FilePath::FromUTF16Unsafe(StringPiece16 utf16) { void FilePath::WriteToPickle(Pickle* pickle) const { #if defined(OS_WIN) - pickle->WriteString16(AsCommonStringPiece(path_)); + pickle->WriteString16(AsStringPiece16(path_)); #elif defined(OS_POSIX) || defined(OS_FUCHSIA) pickle->WriteString(path_); #else |