Hazaar
File
Summary
MethodsPropertiesConstants
No constants
Properties
$__media_uri
$__media_uri
$backend
$backend
$contents
$contents
Static
$default_cipher
$default_cipher
Static
$default_key
$default_key
$encrypted
$encrypted
$filters
$filters
$handle
$handle
$info
$info
$manager
$manager
$mime_content_type
$mime_content_type
$relative_path
$relative_path
$resource
$resource
$source_file
$source_file
Methods
__construct()
__construct($file = null, $backend = null, $manager = null, $relative_path = null)
__destruct()
__destruct()
__tostring()
__tostring()
atime()
atime()
backend()
backend()
base64()
base64() : string
Return the base64 encoded content
basename()
basename()
close()
close() : boolean
Close the file handle if it is currently open
copyTo()
copyTo($destination, $create_dest = false, $dstBackend = null) : mixed
Copy the file to another folder
ctime()
ctime()
decrypt()
decrypt()
Writes the decrypted file to storage
Static
delete()
delete($path)
dir()
dir()
direct_uri()
direct_uri()
dirname()
dirname()
encrypt()
encrypt($write = true)
exists()
exists()
extension()
extension()
filter_in()
filter_in($content)
Internal content filter

Checks if the content is modified in some way using a BOM mask. Currently this is used to determine if a file is encrypted and automatically decrypts it if an encryption key is available.

filter_out()
filter_out($content)
Internal content filter

Checks if the content is modified in some way using a BOM mask. Currently this is used to determine if a file is encrypted and automatically decrypts it if an encryption key is available.

flush()
flush() : boolean
Flushes the output to a file
fullpath()
fullpath()
getBackend()
getBackend()
getEncryptionKey()
getEncryptionKey()
getManager()
getManager()
get_contents()
get_contents($offset = 1, $maxlen = null) : mixed
Returns the current contents of the file.
get_meta()
get_meta($key = null)
get_resource()
get_resource()
getc()
getc() : string
Returns a character from the file pointer
getcsv()
getcsv($length = 0, $delimiter = ',', $enclosure = '"', $escape = '\\') : \array|null
Returns a line from the file pointer and parse for CSV fields
gets()
gets() : string
Returns a line from the file pointer
getss()
getss($allowable_tags = null) : string
Returns a line from the file pointer and strips HTML tags
has_contents()
has_contents()
isEncrypted()
isEncrypted() : boolean
Check if a file is encrypted using the built-in Hazaar encryption method
isOpen()
isOpen() : boolean
Check if the file is currently opened for access by this class

NOTE: This does not include checking if the file is opened by another process or even another Hazaar\File instance.

is_dir()
is_dir()
is_file()
is_file()
is_link()
is_link()
is_readable()
is_readable()
is_writable()
is_writable()
lock()
lock($operation, $wouldblock = null) : boolean
Portable advisory file locking
md5()
md5() : string
Generate an MD5 checksum of the current file content
media_uri()
media_uri($set_path = null)
mime_content_type()
mime_content_type()
moveTo()
moveTo($destination, $create_dest = false, $dstBackend = null)
mtime()
mtime()
name()
name()
open()
open($mode = 'r') : resource
Open a file and return it's file handle

This is useful for using the file with standard (yet unsupported) file functions.

parent()
parent()
parseJSON()
parseJSON($assoc = false) : mixed
Returns the contents as decoded JSON.

If the content is a JSON encoded string, this will decode the string and return it as a stdClass object, or an associative array if the $assoc parameter is TRUE.

If the content can not be decoded because it is not a valid JSON string, this method will return FALSE.

preview_uri()
preview_uri($params = Array ( ) )
put_contents()
put_contents($data, $overwrite = true)
Put contents directly writes data to the storage backend without storing it in the file object itself

NOTE: This function is called internally to save data that has been updated in the file object.

putcsv()
putcsv($fields, $delimiter = ',', $enclosure = '"', $escape = '\\') : integer|null
Writes an array to the file in CSV format.
read()
read($length) : \boolean|string
Binary-safe file read

File::read() reads up to length bytes from the file pointer referenced by handle. Reading stops as soon as one of the following conditions is met:

  • length bytes have been read
  • EOF (end of file) is reached
  • a packet becomes available or the socket timeout occurs (for network streams)
  • if the stream is read buffered and it does not represent a plain file, at most one read of up to a number of bytes equal to the chunk size (usually 8192) is made; depending on the previously buffered data, the size of the returned data may be larger than the chunk size.
readCSV()
readCSV() : array
Return the CSV content as a parsed array
realpath()
realpath()
registerFilter()
registerFilter($type, $callable)
Content filters
relativepath()
relativepath()
rename()
rename($newname) : boolean
Renames a file or directory

NOTE: This will not work if the file is currently opened by another process.

save()
save() : mixed
Saves the current in-memory content to the storage backend.

Internally this calls File::put_contents() to write the data to the backend.

saveAs()
saveAs($filename, $overwrite = false) : mixed
Saves this file objects content to another file name.
seek()
seek($offset, $whence = 'seek_set') : \boolean|integer
Seeks to a position in the file
set_contents()
set_contents($bytes)
Sets the current contents of the file in memory.

Calling this function does not directly update the content of the file "on disk". To do that you must call the File::save() method which will commit the data to storage.

set_decoded_contents()
set_decoded_contents($bytes)
Set the contents from an encoded string.

Currently this supports only data URI encoded strings. I have made this generic in case I come across other types of encodings that will work with this method.

set_meta()
set_meta($values)
set_mime_content_type()
set_mime_content_type($type)
size()
size()
tell()
tell() : \boolean|integer
Returns the current position of the file read/write pointer
thumbnail()
thumbnail($params = Array ( ) )
toArray()
toArray($delimiter = '"\n"')
toString()
toString()
truncate()
truncate($size) : boolean
Truncates a file to a given length
type()
type()
unlink()
unlink() : mixed
Deletes the file from storage
unzip()
unzip($filenames = null, $target = null)
write()
write($string, $length = null) : \boolean|integer
Binary-safe file write

File::write() writes the contents of string to the file stream pointed to by handle.

ziplist()
ziplist()