OpenMediaVault
3.0 (Erasmus)
The open network attached storage solution
|
Public Member Functions | |
__construct ($filename) | |
__destruct () | |
exists () | |
open ($accessMode="w+", $lockMode=LOCK_EX) | |
isOpen () | |
isEmpty () | |
isValid () | |
close () | |
write ($data) | |
getContents () | |
read ($decode=TRUE, $assoc=TRUE) | |
truncate ($size) | |
unlink () | |
Protected Member Functions | |
validate ($data) | |
Read and write JSON encoded content to a file. The file is locked when it is opened and the lock is removed when it is closed.
OMV\Json\File::__construct | ( | $filename | ) |
Constructor
filename | The name of the file. |
OMV\Json\File::__destruct | ( | ) |
Destructor
OMV\Json\File::close | ( | ) |
Close the file.
OMV\Json\File::exists | ( | ) |
Checks whether the file exists.
OMV\Json\File::getContents | ( | ) |
Reads entire file into a string.
OMV\Json\File::isEmpty | ( | ) |
Is the file empty?
OMV\Json\File::isOpen | ( | ) |
Is the file opened?
OMV\Json\File::isValid | ( | ) |
Check if the JSON data is valid.
OMV\Json\File::open | ( | $accessMode = "w+" , |
|
$lockMode = LOCK_EX |
|||
) |
Open the file.
accessMode | The parameter specifies the type of access you require to the stream. Defaults to 'w+'. |
lockMode | The lock mode. Defaults to LOCK_EX. |
OMV\Json\File::read | ( | $decode = TRUE , |
|
$assoc = TRUE |
|||
) |
Read the JSON encoded data from the file.
decode | Set to TRUE to decode the JSON content. Defaults to TRUE. |
OMV\Json\File::truncate | ( | $size | ) |
Truncates the file to a given length.
size | The size to truncate to. |
OMV\Json\File::unlink | ( | ) |
Unlink the given file.
|
protected |
Validate the JSON data.
data | The JSON data to validate. |
OMV\Json\File::write | ( | $data | ) |
Write the given content as JSON encoded string to the file. The file will be truncated to zero length before the content is written.
data | The data to write. |