Memory
extends AbstractFile
in package
Tags
Table of Contents
Properties
- $_data : string
- FileData
- $_position : int
- File Position
Methods
- __construct() : mixed
- Object constractor
- flush() : bool
- Flush output.
- lock() : bool
- Lock file
- readBinary() : string
- Reads binary data from the current position in the file and advances the file pointer.
- readByte() : int
- Reads a byte from the current position in the file and advances the file pointer.
- readBytes() : string
- Read num bytes from the current position in the file and advances the file pointer.
- readInt() : int
- Reads an integer from the current position in the file and advances the file pointer.
- readLong() : int
- Returns a long integer from the current position in the file and advances the file pointer.
- readString() : string
- Reads a string from the current position in the file and advances the file pointer.
- readVInt() : int
- Returns a variable-length integer from the current position in the file and advances the file pointer.
- seek() : int
- Sets the file position indicator and advances the file pointer.
- tell() : int
- Get file position.
- unlock() : void
- Unlock file
- writeByte() : int
- Writes a byte to the end of the file.
- writeBytes() : void
- Writes num bytes of data (all, if $num===null) to the end of the string.
- writeInt() : void
- Writes an integer to the end of file.
- writeLong() : void
- Writes long integer to the end of file
- writeString() : void
- Writes a string to the end of file.
- writeVInt() : void
- Writes a variable-length integer to the end of file.
- _readLong32Bit() : int|float
- Returns a long integer from the current position in the file, advances the file pointer and return it as float (for 32-bit platforms).
- _writeLong32Bit() : void
- Writes long integer to the end of file (32-bit platforms implementation)
- fread() : string
- Reads $length number of bytes at the current position in the file and advances the file pointer.
- fwrite() : void
- Writes $length number of bytes (all, if $length===null) to the end of the file.
Properties
$_data
FileData
private
string
$_data
$_position
File Position
private
int
$_position
= 0
Methods
__construct()
Object constractor
public
__construct(string $data) : mixed
Parameters
- $data : string
flush()
Flush output.
public
flush() : bool
Returns true on success or false on failure.
Return values
boollock()
Lock file
public
lock(int $lockType[, mixed $nonBlockinLock = false ]) : bool
Lock type may be a LOCK_SH (shared lock) or a LOCK_EX (exclusive lock)
Parameters
- $lockType : int
- $nonBlockinLock : mixed = false
Return values
boolreadBinary()
Reads binary data from the current position in the file and advances the file pointer.
public
readBinary() : string
Return values
stringreadByte()
Reads a byte from the current position in the file and advances the file pointer.
public
readByte() : int
Return values
intreadBytes()
Read num bytes from the current position in the file and advances the file pointer.
public
readBytes(int $num) : string
Parameters
- $num : int
Return values
stringreadInt()
Reads an integer from the current position in the file and advances the file pointer.
public
readInt() : int
Return values
intreadLong()
Returns a long integer from the current position in the file and advances the file pointer.
public
readLong() : int
Return values
intreadString()
Reads a string from the current position in the file and advances the file pointer.
public
readString() : string
Return values
stringreadVInt()
Returns a variable-length integer from the current position in the file and advances the file pointer.
public
readVInt() : int
Return values
intseek()
Sets the file position indicator and advances the file pointer.
public
seek(int $offset[, int $whence = SEEK_SET ]) : int
The new position, measured in bytes from the beginning of the file, is obtained by adding offset to the position specified by whence, whose values are defined as follows: SEEK_SET - Set position equal to offset bytes. SEEK_CUR - Set position to current location plus offset. SEEK_END - Set position to end-of-file plus offset. (To move to a position before the end-of-file, you need to pass a negative value in offset.) Upon success, returns 0; otherwise, returns -1
Parameters
- $offset : int
- $whence : int = SEEK_SET
Return values
inttell()
Get file position.
public
tell() : int
Return values
intunlock()
Unlock file
public
unlock() : void
writeByte()
Writes a byte to the end of the file.
public
writeByte(int $byte) : int
Parameters
- $byte : int
Return values
intwriteBytes()
Writes num bytes of data (all, if $num===null) to the end of the string.
public
writeBytes(string $data[, int $num = null ]) : void
Parameters
- $data : string
- $num : int = null
writeInt()
Writes an integer to the end of file.
public
writeInt(int $value) : void
Parameters
- $value : int
writeLong()
Writes long integer to the end of file
public
writeLong(int $value) : void
Parameters
- $value : int
writeString()
Writes a string to the end of file.
public
writeString(string $str) : void
Parameters
- $str : string
Tags
writeVInt()
Writes a variable-length integer to the end of file.
public
writeVInt(int $value) : void
Parameters
- $value : int
_readLong32Bit()
Returns a long integer from the current position in the file, advances the file pointer and return it as float (for 32-bit platforms).
protected
_readLong32Bit() : int|float
Tags
Return values
int|float_writeLong32Bit()
Writes long integer to the end of file (32-bit platforms implementation)
protected
_writeLong32Bit(int|float $value) : void
Parameters
- $value : int|float
Tags
fread()
Reads $length number of bytes at the current position in the file and advances the file pointer.
protected
fread([int $length = 1 ]) : string
Parameters
- $length : int = 1
Return values
stringfwrite()
Writes $length number of bytes (all, if $length===null) to the end of the file.
protected
fwrite(string $data[, int $length = null ]) : void
Parameters
- $data : string
- $length : int = null