Skia
2DGraphicsLibrary
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkFILEStream Class Reference

A stream that wraps a C FILE* file stream. More...

#include <SkStream.h>

Inheritance diagram for SkFILEStream:
SkStreamAsset SkStreamSeekable SkStreamRewindable SkStream

Public Types

enum  Ownership { kCallerPasses_Ownership, kCallerRetains_Ownership }
 

Public Member Functions

 SkFILEStream (const char path[]=NULL)
 Initialize the stream by calling sk_fopen on the specified path. More...
 
 SkFILEStream (FILE *file, Ownership ownership=kCallerPasses_Ownership)
 Initialize the stream with an existing C file stream. More...
 
bool isValid () const
 Returns true if the current path could be opened. More...
 
void setPath (const char path[])
 Close the current file, and open a new file with the specified path. More...
 
size_t read (void *buffer, size_t size) override
 Reads or skips size number of bytes. More...
 
bool isAtEnd () const override
 Returns true when all the bytes in the stream have been read. More...
 
bool rewind () override
 Rewinds to the beginning of the stream. More...
 
SkStreamAssetduplicate () const override
 Duplicates this stream. More...
 
size_t getPosition () const override
 Returns the current position in the stream. More...
 
bool seek (size_t position) override
 Seeks to an absolute position in the stream. More...
 
bool move (long offset) override
 Seeks to an relative offset in the stream. More...
 
SkStreamAssetfork () const override
 Duplicates this stream. More...
 
size_t getLength () const override
 Returns the total length of the stream. More...
 
const void * getMemoryBase () override
 Returns the starting address for the data. More...
 
- Public Member Functions inherited from SkStreamAsset
bool hasLength () const override
 Returns true if this stream can report it's total length. More...
 
- Public Member Functions inherited from SkStreamSeekable
bool hasPosition () const override
 Returns true if this stream can report it's current position. More...
 
- Public Member Functions inherited from SkStream
size_t skip (size_t size)
 Skip size number of bytes. More...
 
virtual size_t peek (void *, size_t) const
 Attempt to peek at size bytes. More...
 
int8_t readS8 ()
 
int16_t readS16 ()
 
int32_t readS32 ()
 
uint8_t readU8 ()
 
uint16_t readU16 ()
 
uint32_t readU32 ()
 
bool readBool ()
 
SkScalar readScalar ()
 
size_t readPackedUInt ()
 

Private Types

typedef SkStreamAsset INHERITED
 

Private Attributes

FILE * fFILE
 
SkString fName
 
Ownership fOwnership
 
sk_sp< SkDatafData
 

Additional Inherited Members

- Static Public Member Functions inherited from SkStream
static SkStreamAssetNewFromFile (const char path[])
 Attempts to open the specified file, and return a stream to it (using mmap if available). More...
 

Detailed Description

A stream that wraps a C FILE* file stream.

Constructor & Destructor Documentation

SkFILEStream::SkFILEStream ( const char  path[] = NULL)
explicit

Initialize the stream by calling sk_fopen on the specified path.

This internal stream will be closed in the destructor.

SkFILEStream::SkFILEStream ( FILE *  file,
Ownership  ownership = kCallerPasses_Ownership 
)
explicit

Initialize the stream with an existing C file stream.

While this stream exists, it assumes exclusive access to the C file stream. The C file stream will be closed in the destructor unless the caller specifies kCallerRetains_Ownership.

Member Function Documentation

SkStreamAsset* SkFILEStream::duplicate ( ) const
overridevirtual

Duplicates this stream.

If this cannot be done, returns NULL. The returned stream will be positioned at the beginning of its data.

Implements SkStreamAsset.

SkStreamAsset* SkFILEStream::fork ( ) const
overridevirtual

Duplicates this stream.

If this cannot be done, returns NULL. The returned stream will be positioned the same as this stream.

Implements SkStreamAsset.

size_t SkFILEStream::getLength ( ) const
overridevirtual

Returns the total length of the stream.

If this cannot be done, returns 0.

Implements SkStreamAsset.

const void* SkFILEStream::getMemoryBase ( )
overridevirtual

Returns the starting address for the data.

If this cannot be done, returns NULL.

Reimplemented from SkStream.

size_t SkFILEStream::getPosition ( ) const
overridevirtual

Returns the current position in the stream.

If this cannot be done, returns 0.

Implements SkStreamSeekable.

bool SkFILEStream::isAtEnd ( ) const
overridevirtual

Returns true when all the bytes in the stream have been read.

This may return true early (when there are no more bytes to be read) or late (after the first unsuccessful read).

Implements SkStream.

bool SkFILEStream::isValid ( ) const
inline

Returns true if the current path could be opened.

bool SkFILEStream::move ( long  )
overridevirtual

Seeks to an relative offset in the stream.

If this cannot be done, returns false. If an attempt is made to move to a position outside the stream, the position will be set to the closest point within the stream (beginning or end).

Implements SkStreamSeekable.

size_t SkFILEStream::read ( void *  buffer,
size_t  size 
)
overridevirtual

Reads or skips size number of bytes.

If buffer == NULL, skip size bytes, return how many were skipped. If buffer != NULL, copy size bytes into buffer, return how many were copied.

Parameters
bufferwhen NULL skip size bytes, otherwise copy size bytes into buffer
sizethe number of bytes to skip or copy
Returns
the number of bytes actually read.

Implements SkStream.

bool SkFILEStream::rewind ( )
overridevirtual

Rewinds to the beginning of the stream.

Returns true if the stream is known to be at the beginning after this call returns.

Implements SkStreamRewindable.

bool SkFILEStream::seek ( size_t  )
overridevirtual

Seeks to an absolute position in the stream.

If this cannot be done, returns false. If an attempt is made to seek past the end of the stream, the position will be set to the end of the stream.

Implements SkStreamSeekable.

void SkFILEStream::setPath ( const char  path[])

Close the current file, and open a new file with the specified path.

If path is NULL, just close the current file.


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