Documentation

LargeFileContent extends SeekableFileContent
in package
implements FileContent

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. :-)

Tags
since
1.3.0

Interfaces, Classes and Traits

FileContent
Interface for actual file contents.

Table of Contents

$content  : mixed
byte array of written content
$offset  : mixed
current position within content
$size  : mixed
file size in bytes
__construct()  : mixed
constructor
bytesRead()  : int
for backwards compatibility with vfsStreamFile::bytesRead()
content()  : string
returns actual content
eof()  : bool
checks whether pointer is at end of file
read()  : string
reads the given amount of bytes from content
readUntilEnd()  : string
for backwards compatibility with vfsStreamFile::readUntilEnd()
seek()  : bool
seeks to the given offset
size()  : int
returns size of content
truncate()  : bool
Truncates a file to a given length
withGigabytes()  : LargeFileContent
create large file with given size in gigabyte
withKilobytes()  : LargeFileContent
create large file with given size in kilobyte
withMegabytes()  : LargeFileContent
create large file with given size in megabyte
write()  : int
writes an amount of data
doRead()  : mixed
actual reading of given byte count starting at given offset
doWrite()  : mixed
actual writing of data with specified length at given offset

Properties

$content

byte array of written content

private mixed $content = array()
Tags
type

char[]

Methods

__construct()

constructor

public __construct(int $size) : mixed
Parameters
$size : int

file size in bytes

Return values
mixed

bytesRead()

for backwards compatibility with vfsStreamFile::bytesRead()

public bytesRead() : int
Tags
deprecated
Return values
int

content()

returns actual content

public content() : string
Return values
string

eof()

checks whether pointer is at end of file

public eof() : bool
Return values
bool

read()

reads the given amount of bytes from content

public read(int $count) : string
Parameters
$count : int
Return values
string

readUntilEnd()

for backwards compatibility with vfsStreamFile::readUntilEnd()

public readUntilEnd() : string
Tags
deprecated
Return values
string

seek()

seeks to the given offset

public seek(int $offset, int $whence) : bool
Parameters
$offset : int
$whence : int
Return values
bool

size()

returns size of content

public size() : int
Return values
int

truncate()

Truncates a file to a given length

public truncate(int $size) : bool
Parameters
$size : int

length to truncate file to

Return values
bool

write()

writes an amount of data

public write(string $data) : int
Parameters
$data : string
Return values
int

amount of written bytes

doRead()

actual reading of given byte count starting at given offset

protected doRead(int $offset, int $count) : mixed
Parameters
$offset : int
$count : int
Return values
mixed

doWrite()

actual writing of data with specified length at given offset

protected doWrite(string $data, int $offset, int $length) : mixed
Parameters
$data : string
$offset : int
$length : int
Return values
mixed

Search results