Nebula
Loading...
Searching...
No Matches
IO::ZipFileStream Class Reference

#include <zipfilestream.h>

Detailed Description

Wraps a file in a zip archive into a stream.

The file is immediately loaded and buffered in a memory buffer and the ZipEntry is closed directly after.

The IO::Server allows transparent access to data in zip files through normal "file:" URIs by first checking whether the file is part of a mounted zip archive. Only if this is not the case, the file will be opened as normal.

To force reading from a zip archive, use an URI of the following format:

zip://[samba server]/bla/blob/archive.zip?file=path/in/zipfile&pwd=password

This assumes that the URI scheme "zip" has been associated with the ZipFileStream class using the IO::Server::RegisterUriScheme() method.

The server and local path part of the URI contain the path to the zip archive file. The query part contains the path of the file in the zip archive and an optional password.

Inherits IO::Stream.

Public Member Functions

 ZipFileStream ()
 constructor
virtual ~ZipFileStream ()
 destructor
virtual bool CanRead () const
 memory streams support reading
virtual bool CanWrite () const
 memory streams support writing
virtual bool CanSeek () const
 memory streams support seeking
virtual bool CanBeMapped () const
 memory streams are mappable
virtual Size GetSize () const
 get the size of the stream in bytes
virtual Position GetPosition () const
 get the current position of the read/write cursor
virtual bool Open ()
 open the stream
virtual void Close ()
 close the stream
virtual Size Read (void *ptr, Size numBytes)
 directly read from the stream
virtual void Seek (Offset offset, SeekOrigin origin)
 seek in stream, only forward seeks are allowed
virtual bool Eof () const
 return true if end-of-stream reached
virtual void * Map ()
 map for direct memory-access
virtual void Unmap ()
 unmap a mapped stream
virtual void * MemoryMap ()
 map for direct memory-access, does nothing but call Map()
virtual void MemoryUnmap ()
 unmap memory stream
Public Member Functions inherited from IO::Stream
 Stream ()
 constructor
virtual ~Stream ()
 destructor
void SetURI (const URI &u)
 set stream location as URI
const URIGetURI () const
 get stream URI
virtual void SetSize (Size s)
 set a new size for the stream
void SetAccessMode (AccessMode m)
 set the access mode of the stream (default is ReadAccess)
AccessMode GetAccessMode () const
 get the access mode of the stream
void SetAccessPattern (AccessPattern p)
 set the prefered access pattern (default is Sequential)
AccessPattern GetAccessPattern () const
 get the prefered access pattern
void SetMediaType (const MediaType &t)
 set optional media type of stream content
const MediaTypeGetMediaType () const
 get optional media type
bool IsOpen () const
 return true if currently open
virtual void Write (const void *ptr, Size numBytes)
 directly write to the stream
virtual void Flush ()
 flush unsaved data
bool IsMapped () const
 return true if stream is currently mapped to memory
Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
int GetRefCount () const
 get the current refcount
void AddRef ()
 increment refcount by one
void Release ()
 decrement refcount and destroy object if refcount is zero
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
const Util::StringGetClassName () const
 get the class name
Util::FourCC GetClassFourCC () const
 get the class FourCC code

Private Member Functions

 __DeclareClass (ZipFileStream)
bool CopyToMap ()
 uncompress all to mapBuffer

Private Attributes

Size size
Position position
ZipFileEntryzipFileEntry
unsigned char * mapBuffer

Additional Inherited Members

Public Types inherited from IO::Stream
enum  AccessMode { ReadAccess , WriteAccess , AppendAccess , ReadWriteAccess }
 access modes More...
enum  AccessPattern { Random , Sequential }
 access prefered pattern More...
enum  SeekOrigin { Begin , Current , End }
 seek origins More...
typedef int64_t Position
 typedefs
typedef int64_t Offset
typedef int64_t Size
Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)
Protected Attributes inherited from IO::Stream
URI uri
AccessMode accessMode
AccessPattern accessPattern
bool isOpen
bool isMapped
MediaType mediaType

Constructor & Destructor Documentation

◆ ZipFileStream()

IO::ZipFileStream::ZipFileStream ( )

constructor

◆ ~ZipFileStream()

IO::ZipFileStream::~ZipFileStream ( )
virtual

destructor

Member Function Documentation

◆ __DeclareClass()

IO::ZipFileStream::__DeclareClass ( ZipFileStream )
private

◆ CanBeMapped()

bool IO::ZipFileStream::CanBeMapped ( ) const
virtual

memory streams are mappable

Reimplemented from IO::Stream.

◆ CanRead()

bool IO::ZipFileStream::CanRead ( ) const
virtual

memory streams support reading

Reimplemented from IO::Stream.

◆ CanSeek()

bool IO::ZipFileStream::CanSeek ( ) const
virtual

memory streams support seeking

Reimplemented from IO::Stream.

◆ CanWrite()

bool IO::ZipFileStream::CanWrite ( ) const
virtual

memory streams support writing

Reimplemented from IO::Stream.

◆ Close()

void IO::ZipFileStream::Close ( )
virtual

close the stream

Reimplemented from IO::Stream.

◆ CopyToMap()

bool IO::ZipFileStream::CopyToMap ( )
private

uncompress all to mapBuffer

◆ Eof()

bool IO::ZipFileStream::Eof ( ) const
virtual

return true if end-of-stream reached

Reimplemented from IO::Stream.

◆ GetPosition()

Stream::Position IO::ZipFileStream::GetPosition ( ) const
virtual

get the current position of the read/write cursor

Reimplemented from IO::Stream.

◆ GetSize()

Stream::Size IO::ZipFileStream::GetSize ( ) const
virtual

get the size of the stream in bytes

Reimplemented from IO::Stream.

◆ Map()

void * IO::ZipFileStream::Map ( )
virtual

map for direct memory-access

Reimplemented from IO::Stream.

◆ MemoryMap()

void * IO::ZipFileStream::MemoryMap ( )
virtual

map for direct memory-access, does nothing but call Map()

Reimplemented from IO::Stream.

◆ MemoryUnmap()

void IO::ZipFileStream::MemoryUnmap ( )
virtual

unmap memory stream

Reimplemented from IO::Stream.

◆ Open()

bool IO::ZipFileStream::Open ( )
virtual

open the stream

Open the stream for reading.

This will decompress the entire file from the zip archive into memory.

Reimplemented from IO::Stream.

◆ Read()

Stream::Size IO::ZipFileStream::Read ( void * ptr,
Size numBytes )
virtual

directly read from the stream

Reimplemented from IO::Stream.

◆ Seek()

void IO::ZipFileStream::Seek ( Offset offset,
SeekOrigin origin )
virtual

seek in stream, only forward seeks are allowed

Reimplemented from IO::Stream.

◆ Unmap()

void IO::ZipFileStream::Unmap ( )
virtual

unmap a mapped stream

Reimplemented from IO::Stream.

Member Data Documentation

◆ mapBuffer

unsigned char* IO::ZipFileStream::mapBuffer
private

◆ position

Position IO::ZipFileStream::position
private

◆ size

Size IO::ZipFileStream::size
private

◆ zipFileEntry

ZipFileEntry* IO::ZipFileStream::zipFileEntry
private

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