[alohalytics] Re-usable FileManager::ScopedRemoveFile.

This commit is contained in:
Alex Zolotarev 2015-06-18 14:53:28 +03:00
parent 3f041ede57
commit 97095e498d
2 changed files with 8 additions and 6 deletions

View file

@ -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.

View file

@ -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() {