Shaka Packager SDK
file_closer.h
1 // Copyright 2014 Google Inc. 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 "packager/base/logging.h"
11 #include "packager/file/file.h"
12 
13 namespace shaka {
14 
17 struct FileCloser {
18  inline void operator()(File* file) const {
19  if (file != NULL) {
20  const std::string filename = file->file_name();
21  if (!file->Close()) {
22  LOG(WARNING) << "Failed to close the file properly: " << filename;
23  }
24  }
25  }
26 };
27 
28 } // namespace shaka
29 
30 #endif // MEDIA_FILE_FILE_CLOSER_H_
Define an abstract file interface.
Definition: file.h:27
const std::string & file_name() const
Definition: file.h:95
virtual bool Close()=0
All the methods that are virtual are virtual for mocking.