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-10-11 21:44:55 +00:00
|
|
|
|
|
|
|
#ifndef PACKAGER_FILE_LOCAL_FILE_H_
|
|
|
|
#define PACKAGER_FILE_LOCAL_FILE_H_
|
|
|
|
|
2014-09-30 23:52:58 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2013-10-11 21:44:55 +00:00
|
|
|
#include <string>
|
|
|
|
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/base/compiler_specific.h"
|
|
|
|
#include "packager/media/file/file.h"
|
2013-10-11 21:44:55 +00:00
|
|
|
|
2014-09-19 20:41:13 +00:00
|
|
|
namespace edash_packager {
|
2013-10-11 21:44:55 +00:00
|
|
|
namespace media {
|
|
|
|
|
2014-01-24 00:26:00 +00:00
|
|
|
/// Implement LocalFile which deals with local storage.
|
2013-10-11 21:44:55 +00:00
|
|
|
class LocalFile : public File {
|
|
|
|
public:
|
2014-01-24 00:26:00 +00:00
|
|
|
/// @param file_name C string containing the name of the file to be accessed.
|
|
|
|
/// @param mode C string containing a file access mode, refer to fopen for
|
|
|
|
/// the available modes.
|
|
|
|
LocalFile(const char* file_name, const char* mode);
|
2013-10-11 21:44:55 +00:00
|
|
|
|
2014-01-24 00:26:00 +00:00
|
|
|
/// @name File implementation overrides.
|
|
|
|
/// @{
|
2013-10-11 21:44:55 +00:00
|
|
|
virtual bool Close() OVERRIDE;
|
2014-09-30 21:52:21 +00:00
|
|
|
virtual int64_t Read(void* buffer, uint64_t length) OVERRIDE;
|
|
|
|
virtual int64_t Write(const void* buffer, uint64_t length) OVERRIDE;
|
|
|
|
virtual int64_t Size() OVERRIDE;
|
2013-10-11 21:44:55 +00:00
|
|
|
virtual bool Flush() OVERRIDE;
|
|
|
|
virtual bool Eof() OVERRIDE;
|
2014-01-24 00:26:00 +00:00
|
|
|
/// @}
|
2013-10-11 21:44:55 +00:00
|
|
|
|
2015-03-11 19:18:17 +00:00
|
|
|
/// Delete a local file.
|
|
|
|
/// @param file_name is the path of the file to be deleted.
|
|
|
|
/// @return true if successful, or false otherwise.
|
|
|
|
static bool Delete(const char* file_name);
|
|
|
|
|
2013-10-11 21:44:55 +00:00
|
|
|
protected:
|
2014-04-08 20:21:07 +00:00
|
|
|
virtual ~LocalFile();
|
2014-01-24 00:26:00 +00:00
|
|
|
|
2013-10-11 21:44:55 +00:00
|
|
|
virtual bool Open() OVERRIDE;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string file_mode_;
|
|
|
|
FILE* internal_file_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(LocalFile);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
2014-09-19 20:41:13 +00:00
|
|
|
} // namespace edash_packager
|
2013-10-11 21:44:55 +00:00
|
|
|
|
|
|
|
#endif // PACKAGER_FILE_LOCAL_FILE_H_
|