FileInterface
in
Tags
Table of Contents
Methods
- 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|float
- 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() : mixed
- Unlock file
- writeByte() : mixed
- Writes a byte to the end of the file.
- writeBytes() : mixed
- Writes num bytes of data (all, if $num===null) to the end of the string.
- writeInt() : mixed
- Writes an integer to the end of file.
- writeLong() : mixed
- Writes long integer to the end of file
- writeString() : mixed
- Writes a string to the end of file.
- writeVInt() : mixed
- Writes a variable-length integer to the end of file.
Methods
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|float
Return values
int|floatreadString()
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() : mixed
writeByte()
Writes a byte to the end of the file.
public
writeByte(int $byte) : mixed
Parameters
- $byte : int
writeBytes()
Writes num bytes of data (all, if $num===null) to the end of the string.
public
writeBytes(string $data[, int $num = null ]) : mixed
Parameters
- $data : string
- $num : int = null
writeInt()
Writes an integer to the end of file.
public
writeInt(int $value) : mixed
Parameters
- $value : int
writeLong()
Writes long integer to the end of file
public
writeLong(int $value) : mixed
Parameters
- $value : int
writeString()
Writes a string to the end of file.
public
writeString(string $str) : mixed
Parameters
- $str : string
writeVInt()
Writes a variable-length integer to the end of file.
public
writeVInt(int $value) : mixed
Parameters
- $value : int