Shaka Player Embedded
file_system.h
Go to the documentation of this file.
1 // Copyright 2017 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef SHAKA_EMBEDDED_UTIL_FILE_SYSTEM_H_
16 #define SHAKA_EMBEDDED_UTIL_FILE_SYSTEM_H_
17 
18 #include <string>
19 #include <vector>
20 
21 #include "src/util/macros.h"
22 
23 namespace shaka {
24 namespace util {
25 
30 class FileSystem {
31  public:
32  FileSystem();
33  virtual ~FileSystem();
34 
35 
37  static std::string PathJoin(const std::string& a, const std::string& b);
38 
40  static std::string DirName(const std::string& path);
41 
43  static std::string GetPathForStaticFile(const std::string& static_data_dir,
44  bool is_bundle_relative,
45  const std::string& file);
46 
48  static std::string GetPathForDynamicFile(const std::string& dynamic_data_dir,
49  const std::string& file);
50 
51 
53  virtual bool FileExists(const std::string& path) const;
54 
56  virtual bool DirectoryExists(const std::string& path) const;
57 
59  virtual ssize_t FileSize(const std::string& path) const;
60 
66  MUST_USE_RESULT virtual bool DeleteFile(const std::string& path) const;
67 
73  MUST_USE_RESULT virtual bool CreateDirectory(const std::string& path) const;
74 
81  MUST_USE_RESULT virtual bool ListFiles(const std::string& path,
82  std::vector<std::string>* files) const;
83 
84 
90  MUST_USE_RESULT virtual bool ReadFile(const std::string& path,
91  std::vector<uint8_t>* data) const;
92 
98  MUST_USE_RESULT virtual bool WriteFile(
99  const std::string& path, const std::vector<uint8_t>& data) const;
100 };
101 
102 } // namespace util
103 } // namespace shaka
104 
105 #endif // SHAKA_EMBEDDED_UTIL_FILE_SYSTEM_H_
static std::string DirName(const std::string &path)
static std::string GetPathForStaticFile(const std::string &static_data_dir, bool is_bundle_relative, const std::string &file)
Definition: file_system.cc:46
virtual MUST_USE_RESULT bool WriteFile(const std::string &path, const std::vector< uint8_t > &data) const
Definition: file_system.cc:105
static std::string GetPathForDynamicFile(const std::string &dynamic_data_dir, const std::string &file)
Definition: file_system.cc:57
virtual MUST_USE_RESULT bool DeleteFile(const std::string &path) const
#define MUST_USE_RESULT
Definition: macros.h:52
virtual bool FileExists(const std::string &path) const
virtual ssize_t FileSize(const std::string &path) const
Definition: file_system.cc:62
virtual MUST_USE_RESULT bool ReadFile(const std::string &path, std::vector< uint8_t > *data) const
Definition: file_system.cc:79
virtual bool DirectoryExists(const std::string &path) const
static std::string PathJoin(const std::string &a, const std::string &b)
virtual MUST_USE_RESULT bool CreateDirectory(const std::string &path) const
virtual MUST_USE_RESULT bool ListFiles(const std::string &path, std::vector< std::string > *files) const