From 97095e498dcb9968a42296ea3b6f894f69e41b5a Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Thu, 18 Jun 2015 14:53:28 +0300 Subject: [PATCH] [alohalytics] Re-usable FileManager::ScopedRemoveFile. --- 3party/Alohalytics/src/file_manager.h | 7 +++++++ 3party/Alohalytics/tests/test_messages_queue.cc | 7 +------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/3party/Alohalytics/src/file_manager.h b/3party/Alohalytics/src/file_manager.h index 326ba5b044..2021120d52 100644 --- a/3party/Alohalytics/src/file_manager.h +++ b/3party/Alohalytics/src/file_manager.h @@ -31,6 +31,13 @@ SOFTWARE. namespace alohalytics { +// Useful helper. +struct ScopedRemoveFile { + std::string file_; + ScopedRemoveFile(const std::string & file) : file_(file) {} + ~ScopedRemoveFile() { std::remove(file_.c_str()); } +}; + // Functions are wrapped into the class for convenience. struct FileManager { // Initialized separately for each platform. diff --git a/3party/Alohalytics/tests/test_messages_queue.cc b/3party/Alohalytics/tests/test_messages_queue.cc index f3bb113c22..66ff7e2640 100644 --- a/3party/Alohalytics/tests/test_messages_queue.cc +++ b/3party/Alohalytics/tests/test_messages_queue.cc @@ -46,13 +46,8 @@ SOFTWARE. } \ } -struct ScopedRemoveFile { - std::string file_; - ScopedRemoveFile(const std::string & file) : file_(file) {} - ~ScopedRemoveFile() { std::remove(file_.c_str()); } -}; - using alohalytics::FileManager; +using alohalytics::ScopedRemoveFile; // Generates unique temporary file name or empty string on error. static std::string GenerateTemporaryFileName() {