Shaka Player Embedded
Public Member Functions | Static Public Member Functions | List of all members
shaka::util::FileSystem Class Reference

#include <file_system.h>

Public Member Functions

 FileSystem ()
 
virtual ~FileSystem ()
 
virtual bool FileExists (const std::string &path) const
 
virtual bool DirectoryExists (const std::string &path) const
 
virtual ssize_t FileSize (const std::string &path) const
 
virtual MUST_USE_RESULT bool DeleteFile (const std::string &path) const
 
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
 
virtual MUST_USE_RESULT bool ReadFile (const std::string &path, std::vector< uint8_t > *data) const
 
virtual MUST_USE_RESULT bool WriteFile (const std::string &path, const std::vector< uint8_t > &data) const
 

Static Public Member Functions

static std::string PathJoin (const std::string &a, const std::string &b)
 
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)
 
static std::string GetPathForDynamicFile (const std::string &dynamic_data_dir, const std::string &file)
 

Detailed Description

An abstraction of the file system. This manages interactions with the file system like reading and writing files.

Definition at line 30 of file file_system.h.

Constructor & Destructor Documentation

§ FileSystem()

shaka::util::FileSystem::FileSystem ( )

Definition at line 42 of file file_system.cc.

§ ~FileSystem()

shaka::util::FileSystem::~FileSystem ( )
virtual

Definition at line 43 of file file_system.cc.

Member Function Documentation

§ CreateDirectory()

bool shaka::util::FileSystem::CreateDirectory ( const std::string &  path) const
virtual

Creates a directory (and any parent directories) at the given path.

Parameters
pathThe path to the directory to create.
Returns
True on success, false on error.

Definition at line 68 of file file_system_posix.cc.

§ DeleteFile()

bool shaka::util::FileSystem::DeleteFile ( const std::string &  path) const
virtual

Deletes the given file, file must already exist.

Parameters
pathThe path to the file to delete.
Returns
True on success, false on error.

Definition at line 64 of file file_system_posix.cc.

§ DirectoryExists()

bool shaka::util::FileSystem::DirectoryExists ( const std::string &  path) const
virtual
Returns
Whether the given directory exists (must be a directory).

Definition at line 59 of file file_system_posix.cc.

§ DirName()

std::string shaka::util::FileSystem::DirName ( const std::string &  path)
static
Returns
The directory name of the given path.

Definition at line 45 of file file_system_posix.cc.

§ FileExists()

bool shaka::util::FileSystem::FileExists ( const std::string &  path) const
virtual
Returns
Whether the given file exists (must be a file).

Definition at line 53 of file file_system_posix.cc.

§ FileSize()

ssize_t shaka::util::FileSystem::FileSize ( const std::string &  path) const
virtual
Returns
The size of the given file, or -1 on error.

Definition at line 62 of file file_system.cc.

§ GetPathForDynamicFile()

std::string shaka::util::FileSystem::GetPathForDynamicFile ( const std::string &  dynamic_data_dir,
const std::string &  file 
)
static
Returns
The full path to the given dynamic file.

Definition at line 57 of file file_system.cc.

§ GetPathForStaticFile()

std::string shaka::util::FileSystem::GetPathForStaticFile ( const std::string &  static_data_dir,
bool  is_bundle_relative,
const std::string &  file 
)
static
Returns
The full path to the given static file.

Definition at line 46 of file file_system.cc.

§ ListFiles()

bool shaka::util::FileSystem::ListFiles ( const std::string &  path,
std::vector< std::string > *  files 
) const
virtual

Lists the files that are in the given directory.

Parameters
pathThe path to the directory to search.
files[OUT] Will contain the names of the files contained.
Returns
True on success, false on error.

Definition at line 78 of file file_system_posix.cc.

§ PathJoin()

std::string shaka::util::FileSystem::PathJoin ( const std::string &  a,
const std::string &  b 
)
static
Returns
A path that is the result of combining a and b.

Definition at line 34 of file file_system_posix.cc.

§ ReadFile()

bool shaka::util::FileSystem::ReadFile ( const std::string &  path,
std::vector< uint8_t > *  data 
) const
virtual
Parameters
pathThe path of the file to read.
data[OUT] Where to put the contents of the file.
Returns
True on success, false on error.

Definition at line 79 of file file_system.cc.

§ WriteFile()

bool shaka::util::FileSystem::WriteFile ( const std::string &  path,
const std::vector< uint8_t > &  data 
) const
virtual
Parameters
pathThe path of the file to write to.
dataThe data to write into the file.
Returns
True on success, false on error.

Definition at line 105 of file file_system.cc.


The documentation for this class was generated from the following files: