File content implementation to mock large files.

When content is written via write() the data will be written into the positions according to the current offset. When content is read via read() it will use the already written data. If no data is written at the offsets to read those offsets will be filled with spaces. Please note that accessing the whole content via content() will deliver a string with the length of the originally defined size. It is not advisable to do so with large sizes, except you have enough memory and time. :-)

since 1.3.0

 Methods

constructor

__construct(int $size) 

Parameters

$size

int

file size in bytes

for backwards compatibility with vfsStreamFile::bytesRead()

bytesRead() : int
Inherited

inherited_from \org\bovigo\vfs\content\SeekableFileContent::bytesRead()

Returns

int

returns actual content

content() : string

Returns

string

checks whether pointer is at end of file

eof() : bool
Inherited

inherited_from \org\bovigo\vfs\content\FileContent::eof()

Returns

bool

reads the given amount of bytes from content

read(int $count) : string
Inherited

inherited_from \org\bovigo\vfs\content\FileContent::read()

Parameters

$count

int

Returns

string

for backwards compatibility with vfsStreamFile::readUntilEnd()

readUntilEnd() : string
Inherited

inherited_from \org\bovigo\vfs\content\SeekableFileContent::readUntilEnd()

Returns

string

seeks to the given offset

seek(int $offset, int $whence) : bool
Inherited

inherited_from \org\bovigo\vfs\content\FileContent::seek()

Parameters

$offset

int

$whence

int

Returns

bool

returns size of content

size() : int

Returns

int

Truncates a file to a given length

truncate(int $size) : bool

Parameters

$size

int

length to truncate file to

Returns

bool

create large file with given size in gigabyte

withGigabytes(int $gigabyte) : \org\bovigo\vfs\content\LargeFileContent

Parameters

$gigabyte

int

Returns

create large file with given size in kilobyte

withKilobytes(int $kilobyte) : \org\bovigo\vfs\content\LargeFileContent

Parameters

$kilobyte

int

Returns

create large file with given size in megabyte

withMegabytes(int $megabyte) : \org\bovigo\vfs\content\LargeFileContent

Parameters

$megabyte

int

Returns

writes an amount of data

write(string $data) : \org\bovigo\vfs\content\amount
Inherited

inherited_from \org\bovigo\vfs\content\FileContent::write()

Parameters

$data

string

Returns

\org\bovigo\vfs\content\amountof written bytes

actual reading of given byte count starting at given offset

doRead(int $offset, int $count) 

Parameters

$offset

int

$count

int

actual writing of data with specified length at given offset

doWrite(string $data, int $offset, int $length) 

Parameters

$data

string

$offset

int

$length

int

 Properties

 

byte array of written content

$content 

type char[]
 

current position within content

$offset 
Inherited

type int
inherited_from \org\bovigo\vfs\content\SeekableFileContent::$$offset
 

file size in bytes

$size 

type int