• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // Gets the contents file_name as a string. Returns false on error.
26 bool GetFileContents(const std::string& file_name, std::string* contents);
27 
28 // Manages life of temporary file specified at time of construction. Deletes
29 // file upon destruction.
30 class TempFileDeleter {
31  public:
32   TempFileDeleter();
TempFileDeleter(std::string file_name)33   explicit TempFileDeleter(std::string file_name) : file_name_(file_name) {}
34   ~TempFileDeleter();
name()35   const std::string& name() const { return file_name_; }
36 
37  private:
38   std::string file_name_;
39   LIBWEBM_DISALLOW_COPY_AND_ASSIGN(TempFileDeleter);
40 };
41 
42 }  // namespace libwebm
43 
44 #endif  // LIBWEBM_COMMON_FILE_UTIL_H_
45