Shaka Packager SDK
file_closer.h
1 // Copyright 2014 Google LLC. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef MEDIA_FILE_FILE_CLOSER_H_
8 #define MEDIA_FILE_FILE_CLOSER_H_
9 
10 #include <absl/log/log.h>
11 
12 #include <packager/file.h>
13 
14 namespace shaka {
15 
18 struct FileCloser {
19  inline void operator()(File* file) const {
20  if (file != NULL) {
21  const std::string filename = file->file_name();
22  if (!file->Close()) {
23  LOG(WARNING) << "Failed to close the file properly: " << filename;
24  }
25  }
26  }
27 };
28 
29 } // namespace shaka
30 
31 #endif // MEDIA_FILE_FILE_CLOSER_H_
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66