OLD | NEW |
1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "testing/test_support.h" | 5 #include "testing/test_support.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include "testing/utils/path_service.h" | 10 #include "testing/utils/path_service.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 unsigned long pos, | 164 unsigned long pos, |
165 unsigned char* pBuf, | 165 unsigned char* pBuf, |
166 unsigned long size) { | 166 unsigned long size) { |
167 TestLoader* pLoader = static_cast<TestLoader*>(param); | 167 TestLoader* pLoader = static_cast<TestLoader*>(param); |
168 if (pos + size < pos || pos + size > pLoader->m_Len) | 168 if (pos + size < pos || pos + size > pLoader->m_Len) |
169 return 0; | 169 return 0; |
170 | 170 |
171 memcpy(pBuf, pLoader->m_pBuf + pos, size); | 171 memcpy(pBuf, pLoader->m_pBuf + pos, size); |
172 return 1; | 172 return 1; |
173 } | 173 } |
| 174 |
| 175 TestSaver::TestSaver() { |
| 176 FPDF_FILEWRITE::version = 1; |
| 177 FPDF_FILEWRITE::WriteBlock = WriteBlockCallback; |
| 178 } |
| 179 |
| 180 void TestSaver::ClearString() { |
| 181 m_String.clear(); |
| 182 } |
| 183 |
| 184 // static |
| 185 int TestSaver::WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, |
| 186 const void* data, |
| 187 unsigned long size) { |
| 188 TestSaver* pThis = static_cast<TestSaver*>(pFileWrite); |
| 189 pThis->m_String.append(static_cast<const char*>(data), size); |
| 190 return 1; |
| 191 } |
OLD | NEW |