From f2b940ce281ac5b690bf661fb686fcb5eed34d02 Mon Sep 17 00:00:00 2001 From: thestig Date: Thu, 13 Oct 2016 06:48:47 -0700 Subject: Reduce missing evt file spam in pdfium_test. Review-Url: https://codereview.chromium.org/2415663003 --- samples/pdfium_test.cc | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc index 5c0f81b1b0..9bbd771780 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 +#else +#include +#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 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 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); + } } } } -- cgit v1.2.3