Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Unified Diff: samples/pdfium_test.cc

Issue 2415663003: Reduce missing evt file spam in pdfium_test. (Closed)
Patch Set: R_OK Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/pdfium_test.cc
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index 5c0f81b1b0a7f3b5799e6e1186a5561b70b6a674..9bbd7717807459151777cac1ef8dc83588b342de 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -26,20 +26,28 @@
#include "samples/image_diff_png.h"
#include "testing/test_support.h"
+#ifdef _WIN32
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
#ifdef PDF_ENABLE_V8
#include "v8/include/libplatform/libplatform.h"
#include "v8/include/v8.h"
#endif // PDF_ENABLE_V8
-#ifdef _WIN32
-#define snprintf _snprintf
-#endif
-
#ifdef PDF_ENABLE_SKIA
#include "third_party/skia/include/core/SkPictureRecorder.h"
#include "third_party/skia/include/core/SkStream.h"
#endif
+#ifdef _WIN32
+#define access _access
+#define snprintf _snprintf
+#define R_OK 4
+#endif
+
enum OutputFormat {
OUTPUT_NONE,
OUTPUT_TEXT,
@@ -905,11 +913,15 @@ int main(int argc, const char* argv[]) {
size_t extension_pos = event_filename.find(".pdf");
if (extension_pos != std::string::npos) {
event_filename.replace(extension_pos, 4, ".evt");
- std::unique_ptr<char, pdfium::FreeDeleter> event_contents =
- GetFileContents(event_filename.c_str(), &event_length);
- if (event_contents) {
- fprintf(stderr, "Sending events from: %s\n", event_filename.c_str());
- events = std::string(event_contents.get(), event_length);
+ if (access(event_filename.c_str(), R_OK) == 0) {
+ fprintf(stderr, "Using event file %s.\n", event_filename.c_str());
+ std::unique_ptr<char, pdfium::FreeDeleter> event_contents =
+ GetFileContents(event_filename.c_str(), &event_length);
+ if (event_contents) {
+ fprintf(stderr, "Sending events from: %s\n",
+ event_filename.c_str());
+ events = std::string(event_contents.get(), event_length);
+ }
}
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698