Define an abstract file interface.
More...
#include <file.h>
|
virtual bool | Close ()=0 |
|
virtual int64_t | Read (void *buffer, uint64_t length)=0 |
|
virtual int64_t | Write (const void *buffer, uint64_t length)=0 |
|
virtual int64_t | Size ()=0 |
|
virtual bool | Flush ()=0 |
|
virtual bool | Seek (uint64_t position)=0 |
|
virtual bool | Tell (uint64_t *position)=0 |
|
const std::string & | file_name () const |
|
|
| File (const std::string &file_name) |
|
virtual | ~File () |
|
virtual bool | Open ()=0 |
| Internal open. Should not be used directly.
|
|
Define an abstract file interface.
Definition at line 24 of file file.h.
virtual shaka::media::File::~File |
( |
| ) |
|
|
inlineprotectedvirtual |
Do not call the destructor directly (with the "delete" keyword) nor use std::unique_ptr; instead use Close().
Definition at line 132 of file file.h.
virtual bool shaka::media::File::Close |
( |
| ) |
|
|
pure virtual |
bool shaka::media::File::Copy |
( |
const char * |
from_file_name, |
|
|
const char * |
to_file_name |
|
) |
| |
|
static |
Copies files. This is not good for copying huge files. Although not recommended, it is safe to have source file and destination file name be the same.
- Parameters
-
from_file_name | is the source file name. |
to_file_name | is the destination file name. |
- Returns
- true on success, false otherwise.
Definition at line 204 of file file.cc.
int64_t shaka::media::File::CopyFile |
( |
File * |
source, |
|
|
File * |
destination |
|
) |
| |
|
static |
Copies the contents from source to destination.
- Parameters
-
source | The file to copy from. |
destination | The file to copy to. |
- Returns
- Number of bytes written, or a value < 0 on error.
Definition at line 233 of file file.cc.
int64_t shaka::media::File::CopyFile |
( |
File * |
source, |
|
|
File * |
destination, |
|
|
int64_t |
max_copy |
|
) |
| |
|
static |
Copies the contents from source to destination.
- Parameters
-
source | The file to copy from. |
destination | The file to copy to. |
max_copy | The maximum number of bytes to copy; < 0 to copy to EOF. |
- Returns
- Number of bytes written, or a value < 0 on error.
Definition at line 237 of file file.cc.
bool shaka::media::File::Delete |
( |
const char * |
file_name | ) |
|
|
static |
Delete the specified file.
- Parameters
-
file_name | contains the path of the file to be deleted. |
- Returns
- true if successful, false otherwise.
Definition at line 164 of file file.cc.
const std::string& shaka::media::File::file_name |
( |
| ) |
const |
|
inline |
- Returns
- The file name.
Definition at line 91 of file file.h.
virtual bool shaka::media::File::Flush |
( |
| ) |
|
|
pure virtual |
int64_t shaka::media::File::GetFileSize |
( |
const char * |
file_name | ) |
|
|
static |
- Returns
- The size of a file in bytes on success, a value < 0 otherwise. The file will be opened and closed in the process.
Definition at line 177 of file file.cc.
File * shaka::media::File::Open |
( |
const char * |
file_name, |
|
|
const char * |
mode |
|
) |
| |
|
static |
Open the specified file. This is a file factory method, it opens a proper file automatically based on prefix, e.g. "file://" for LocalFile.
- Parameters
-
file_name | contains the name of the file to be accessed. |
mode | contains file access mode. Implementation dependent. |
- Returns
- A File pointer on success, false otherwise.
Definition at line 142 of file file.cc.
File * shaka::media::File::OpenWithNoBuffering |
( |
const char * |
file_name, |
|
|
const char * |
mode |
|
) |
| |
|
static |
Open the specified file in direct-access mode (no buffering). This is a file factory method, it opens a proper file automatically based on prefix, e.g. "file://" for LocalFile.
- Parameters
-
file_name | contains the name of the file to be accessed. |
mode | contains file access mode. Implementation dependent. |
- Returns
- A File pointer on success, false otherwise.
Definition at line 153 of file file.cc.
virtual int64_t shaka::media::File::Read |
( |
void * |
buffer, |
|
|
uint64_t |
length |
|
) |
| |
|
pure virtual |
bool shaka::media::File::ReadFileToString |
( |
const char * |
file_name, |
|
|
std::string * |
contents |
|
) |
| |
|
static |
Read the file into string.
- Parameters
-
file_name | is the file to be read. It should be a valid file. |
contents[out] | points to the output string. Should not be NULL. |
- Returns
- true on success, false otherwise.
Definition at line 186 of file file.cc.
virtual bool shaka::media::File::Seek |
( |
uint64_t |
position | ) |
|
|
pure virtual |
virtual int64_t shaka::media::File::Size |
( |
| ) |
|
|
pure virtual |
virtual bool shaka::media::File::Tell |
( |
uint64_t * |
position | ) |
|
|
pure virtual |
virtual int64_t shaka::media::File::Write |
( |
const void * |
buffer, |
|
|
uint64_t |
length |
|
) |
| |
|
pure virtual |
The documentation for this class was generated from the following files: