summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfattachment.cpp
diff options
context:
space:
mode:
authorJane Liu <janeliulwq@google.com>2017-07-25 18:11:27 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-27 13:52:39 +0000
commitf63e8133d7a767c6f162e700056ae8ba8512820d (patch)
treef0a8aab3dfb06b5c121d4f3350bf97aeceab4d7e /fpdfsdk/fpdfattachment.cpp
parentf9d60598992f3d9ce2f4b5860a7835fa44d55c88 (diff)
downloadpdfium-f63e8133d7a767c6f162e700056ae8ba8512820d.tar.xz
Added FPDFDoc_DeleteAttachment()
Added an API for deleting an attachment and an embedder test for it. Bug=pdfium:174 Change-Id: I97a1367a197bceb96ecef55c36b1599beccd95a6 Reviewed-on: https://pdfium-review.googlesource.com/8932 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfattachment.cpp')
-rw-r--r--fpdfsdk/fpdfattachment.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfattachment.cpp b/fpdfsdk/fpdfattachment.cpp
index 78fccf4d60..0cb623f81c 100644
--- a/fpdfsdk/fpdfattachment.cpp
+++ b/fpdfsdk/fpdfattachment.cpp
@@ -112,6 +112,19 @@ DLLEXPORT FPDF_ATTACHMENT STDCALL FPDFDoc_GetAttachment(FPDF_DOCUMENT document,
return nameTree.LookupValueAndName(index, &csName);
}
+DLLEXPORT FPDF_BOOL STDCALL FPDFDoc_DeleteAttachment(FPDF_DOCUMENT document,
+ int index) {
+ CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
+ if (!pDoc || index < 0)
+ return false;
+
+ CPDF_NameTree nameTree(pDoc, "EmbeddedFiles");
+ if (static_cast<size_t>(index) >= nameTree.GetCount())
+ return false;
+
+ return nameTree.DeleteValueAndName(index);
+}
+
DLLEXPORT unsigned long STDCALL
FPDFAttachment_GetName(FPDF_ATTACHMENT attachment,
void* buffer,