2014-02-14 23:21:05 +00:00
|
|
|
// Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
2013-11-12 20:37:58 +00:00
|
|
|
|
|
|
|
#ifndef MEDIA_FILE_FILE_CLOSER_H_
|
|
|
|
#define MEDIA_FILE_FILE_CLOSER_H_
|
|
|
|
|
|
|
|
#include "base/logging.h"
|
|
|
|
#include "media/file/file.h"
|
|
|
|
|
2014-09-19 20:41:13 +00:00
|
|
|
namespace edash_packager {
|
2013-11-12 20:37:58 +00:00
|
|
|
namespace media {
|
|
|
|
|
2014-01-24 00:26:00 +00:00
|
|
|
/// Used by scoped_ptr to automatically close the file when it goes out of
|
|
|
|
/// scope.
|
2013-11-12 20:37:58 +00:00
|
|
|
struct FileCloser {
|
|
|
|
inline void operator()(File* file) const {
|
|
|
|
if (file != NULL && !file->Close()) {
|
|
|
|
LOG(WARNING) << "Failed to close the file properly: "
|
|
|
|
<< file->file_name();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
2014-09-19 20:41:13 +00:00
|
|
|
} // namespace edash_packager
|
2013-11-12 20:37:58 +00:00
|
|
|
|
|
|
|
#endif // MEDIA_FILE_FILE_CLOSER_H_
|