Add file_util.

Move file utility classes and functions from testing/test_util to
common/file_util, and make them part of libwebm.

Change-Id: If5b25a63b20efacc16b0fecaa8876ade4ecc4b26
This commit is contained in:
Tom Finegan
2016-03-07 11:08:14 -08:00
parent 87f9beae01
commit e6a0033a8c
9 changed files with 116 additions and 67 deletions

View File

@@ -51,28 +51,7 @@ std::string GetTestFilePath(const std::string& name);
// files match exactly, false otherwise.
bool CompareFiles(const std::string& file1, const std::string& file2);
// Returns a temporary file name.
std::string GetTempFileName();
// Returns size of file specified by |file_name|, or 0 upon failure.
std::uint64_t GetFileSize(const std::string& file_name);
// Manages life of temporary file specified at time of construction. Deletes
// file upon destruction.
class TempFileDeleter {
public:
TempFileDeleter();
explicit TempFileDeleter(std::string file_name) : file_name_(file_name) {}
~TempFileDeleter();
TempFileDeleter(const TempFileDeleter&) = delete;
TempFileDeleter(TempFileDeleter&&) = delete;
const std::string& name() const { return file_name_; }
private:
std::string file_name_;
};
} // namespace test
} // namespace libwebm
#endif // LIBWEBM_TESTING_TEST_UTIL_H_
#endif // LIBWEBM_TESTING_TEST_UTIL_H_