diff options
author | Jane Liu <janeliulwq@google.com> | 2017-07-13 10:37:59 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-07-13 15:18:44 +0000 |
commit | c8a17e550d4d4a6f68598f8eed70eb6f8f301442 (patch) | |
tree | 9b6820db32d532689d086608233b9587216b0197 /core/fpdfdoc/cpdf_filespec.cpp | |
parent | c3eca649ce2213b06551e8de8793e24ec6f9cef5 (diff) | |
download | pdfium-c8a17e550d4d4a6f68598f8eed70eb6f8f301442.tar.xz |
Changed CPDF_FileSpec::GetFileName() to directly return CFX_WideString
Changed CPDF_FileSpec::GetFileName() to directly return CFX_WideString,
instead of taking in a CFX_WideString* and returning a bool. Also fixed
test calls in the unit test.
Bug=pdfium:808
Change-Id: Ie081fc9f4f1c15d23c86d7222d8480ab9cb56056
Reviewed-on: https://pdfium-review.googlesource.com/7671
Commit-Queue: Jane Liu <janeliulwq@google.com>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfdoc/cpdf_filespec.cpp')
-rw-r--r-- | core/fpdfdoc/cpdf_filespec.cpp | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/core/fpdfdoc/cpdf_filespec.cpp b/core/fpdfdoc/cpdf_filespec.cpp index 7d1f0e68b9..5ef6f466c5 100644 --- a/core/fpdfdoc/cpdf_filespec.cpp +++ b/core/fpdfdoc/cpdf_filespec.cpp @@ -89,36 +89,31 @@ CFX_WideString CPDF_FileSpec::DecodeFileName(const CFX_WideString& filepath) { #endif } -bool CPDF_FileSpec::GetFileName(CFX_WideString* csFileName) const { +CFX_WideString CPDF_FileSpec::GetFileName() const { + CFX_WideString csFileName; if (CPDF_Dictionary* pDict = m_pObj->AsDictionary()) { - *csFileName = pDict->GetUnicodeTextFor("UF"); - if (csFileName->IsEmpty()) { - *csFileName = + csFileName = pDict->GetUnicodeTextFor("UF"); + if (csFileName.IsEmpty()) { + csFileName = CFX_WideString::FromLocal(pDict->GetStringFor("F").AsStringC()); } if (pDict->GetStringFor("FS") == "URL") - return true; - if (csFileName->IsEmpty()) { - if (pDict->KeyExist("DOS")) { - *csFileName = - CFX_WideString::FromLocal(pDict->GetStringFor("DOS").AsStringC()); - } else if (pDict->KeyExist("Mac")) { - *csFileName = - CFX_WideString::FromLocal(pDict->GetStringFor("Mac").AsStringC()); - } else if (pDict->KeyExist("Unix")) { - *csFileName = - CFX_WideString::FromLocal(pDict->GetStringFor("Unix").AsStringC()); - } else { - return false; + return csFileName; + + if (csFileName.IsEmpty()) { + constexpr const char* keys[] = {"DOS", "Mac", "Unix"}; + for (const auto* key : keys) { + if (pDict->KeyExist(key)) { + csFileName = + CFX_WideString::FromLocal(pDict->GetStringFor(key).AsStringC()); + break; + } } } } else if (m_pObj->IsString()) { - *csFileName = CFX_WideString::FromLocal(m_pObj->GetString().AsStringC()); - } else { - return false; + csFileName = CFX_WideString::FromLocal(m_pObj->GetString().AsStringC()); } - *csFileName = DecodeFileName(*csFileName); - return true; + return DecodeFileName(csFileName); } CPDF_Stream* CPDF_FileSpec::GetFileStream() const { |