DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerator
local_file.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 PACKAGER_FILE_LOCAL_FILE_H_
8 #define PACKAGER_FILE_LOCAL_FILE_H_
9 
10 #include <stdint.h>
11 
12 #include <string>
13 
14 #include "packager/base/compiler_specific.h"
15 #include "packager/media/file/file.h"
16 
17 namespace edash_packager {
18 namespace media {
19 
21 class LocalFile : public File {
22  public:
26  LocalFile(const char* file_name, const char* mode);
27 
30  bool Close() override;
31  int64_t Read(void* buffer, uint64_t length) override;
32  int64_t Write(const void* buffer, uint64_t length) override;
33  int64_t Size() override;
34  bool Flush() override;
35  bool Seek(uint64_t position) override;
36  bool Tell(uint64_t* position) override;
38 
42  static bool Delete(const char* file_name);
43 
44  protected:
45  ~LocalFile() override;
46 
47  bool Open() override;
48 
49  private:
50  std::string file_mode_;
51  FILE* internal_file_;
52 
53  DISALLOW_COPY_AND_ASSIGN(LocalFile);
54 };
55 
56 } // namespace media
57 } // namespace edash_packager
58 
59 #endif // PACKAGER_FILE_LOCAL_FILE_H_
Define an abstract file interface.
Definition: file.h:23
LocalFile(const char *file_name, const char *mode)
Definition: local_file.cc:17
bool Tell(uint64_t *position) override
Definition: local_file.cc:68
const std::string & file_name() const
Definition: file.h:90
int64_t Write(const void *buffer, uint64_t length) override
Definition: local_file.cc:36
int64_t Read(void *buffer, uint64_t length) override
Definition: local_file.cc:30
bool Seek(uint64_t position) override
Definition: local_file.cc:64
static bool Delete(const char *file_name)
Definition: local_file.cc:84
Implement LocalFile which deals with local storage.
Definition: local_file.h:21
bool Open() override
Internal open. Should not be used directly.
Definition: local_file.cc:78