file_util.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright (c) 2016 The WebM project authors. All Rights Reserved.
  2. //
  3. // Use of this source code is governed by a BSD-style license
  4. // that can be found in the LICENSE file in the root of the source
  5. // tree. An additional intellectual property rights grant can be found
  6. // in the file PATENTS. All contributing project authors may
  7. // be found in the AUTHORS file in the root of the source tree.
  8. #ifndef LIBWEBM_COMMON_FILE_UTIL_H_
  9. #define LIBWEBM_COMMON_FILE_UTIL_H_
  10. #include <stdint.h>
  11. #include <string>
  12. #include "mkvmuxer/mkvmuxertypes.h" // LIBWEBM_DISALLOW_COPY_AND_ASSIGN()
  13. namespace libwebm {
  14. // Returns a temporary file name.
  15. std::string GetTempFileName();
  16. // Returns size of file specified by |file_name|, or 0 upon failure.
  17. uint64_t GetFileSize(const std::string& file_name);
  18. // Manages life of temporary file specified at time of construction. Deletes
  19. // file upon destruction.
  20. class TempFileDeleter {
  21. public:
  22. TempFileDeleter();
  23. explicit TempFileDeleter(std::string file_name) : file_name_(file_name) {}
  24. ~TempFileDeleter();
  25. const std::string& name() const { return file_name_; }
  26. private:
  27. std::string file_name_;
  28. LIBWEBM_DISALLOW_COPY_AND_ASSIGN(TempFileDeleter);
  29. };
  30. } // namespace libwebm
  31. #endif // LIBWEBM_COMMON_FILE_UTIL_H_