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 11 #include <stdint.h> 12 13 #include <string> 14 15 #include "mkvmuxer/mkvmuxertypes.h" // LIBWEBM_DISALLOW_COPY_AND_ASSIGN() 16 17 namespace libwebm { 18 19 // Returns a temporary file name. 20 std::string GetTempFileName(); 21 22 // Returns size of file specified by |file_name|, or 0 upon failure. 23 uint64_t GetFileSize(const std::string& file_name); 24 25 // Manages life of temporary file specified at time of construction. Deletes 26 // file upon destruction. 27 class TempFileDeleter { 28 public: 29 TempFileDeleter(); TempFileDeleter(std::string file_name)30 explicit TempFileDeleter(std::string file_name) : file_name_(file_name) {} 31 ~TempFileDeleter(); name()32 const std::string& name() const { return file_name_; } 33 34 private: 35 std::string file_name_; 36 LIBWEBM_DISALLOW_COPY_AND_ASSIGN(TempFileDeleter); 37 }; 38 39 } // namespace libwebm 40 41 #endif // LIBWEBM_COMMON_FILE_UTIL_H_