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_
shaka::File::file_name
const std::string & file_name() const
Definition: file.h:96
shaka
All the methods that are virtual are virtual for mocking.
Definition: gflags_hex_bytes.cc:11
shaka::File::Close
virtual bool Close()=0
shaka::FileCloser
Definition: file_closer.h:17
shaka::File
Define an abstract file interface.
Definition: file.h:28