\Hazaar\File
GZFile
Summary
Methods Properties Constants
dir
md5
No constants
Properties
Inherited
$backend
$backend
Inherited
$contents
$contents
InheritedStatic
$default_cipher
$default_cipher
InheritedStatic
$default_key
$default_key
Inherited
$handle
$handle
Inherited
$info
$info
Inherited
$manager
$manager
Inherited
$mime_content_type
$mime_content_type
Inherited
$resource
$resource
Inherited
$source_file
$source_file
Methods
__construct()
__construct($file = null, $backend = null)

Parameters

$file

No description

$backend

No description

close()
close()
getc()
getc() : string
Returns a character from the file pointer

Returns

string
gets()
gets() : string
Returns a line from the file pointer

Returns

string
getss()
getss($allowable_tags = null) : string
Returns a line from the file pointer and strips HTML tags

Parameters

$allowable_tags

No description

Returns

string
open()
open($mode = 'r')

Parameters

$mode

No description

Inherited
basename()
basename()
Inherited
close()
close() : boolean
Close the file handle if it is currently open

Returns

boolean
Inherited
copyTo()
copyTo($destination, $create_dest = false, $dstBackend = null)

Parameters

$destination

No description

$create_dest

No description

$dstBackend

No description

Inherited
ctime()
ctime()
Inherited
decrypt()
decrypt()
Writes the decrypted file to storage
InheritedStatic
delete()
delete($path)

Parameters

$path

No description

Inherited
dir()
dir()
Inherited
direct_uri()
direct_uri()
Inherited
dirname()
dirname()
Inherited
encrypt()
encrypt($write = true)

Parameters

$write

No description

Inherited
exists()
exists()
Inherited
extension()
extension()
Inherited
flush()
flush() : boolean
Flushes the output to a file

Returns

boolean
Inherited
fullpath()
fullpath()
Inherited
get_contents()
get_contents($offset = 1, $maxlen = null) : mixed
Returns the current contents of the file.

Parameters

$offsetmixed

No description

$maxlenmixed

No description

Returns

mixed
Inherited
get_meta()
get_meta($key = null)

Parameters

$key

No description

Inherited
getc()
getc() : string
Returns a character from the file pointer

Returns

string
Inherited
getcsv()
getcsv($length = 0, $delimiter = ',', $enclosure = '"', $escape = '\\') : \array|null
Returns a line from the file pointer and parse for CSV fields

Parameters

$lengthmixed

Must be greater than the longest line (in characters) to be found in the CSV file (allowing for trailing line-end characters). Otherwise the line is split in chunks of length characters, unless the split would occur inside an enclosure.

Omitting this parameter (or setting it to 0 in PHP 5.1.0 and later) the maximum line length is not limited, which is slightly slower.
$delimitermixed

The optional delimiter parameter sets the field delimiter (one character only).

$enclosuremixed

The optional enclosure parameter sets the field enclosure character (one character only).

$escapemixed

The optional escape parameter sets the escape character (one character only).

Returns

\array|null
Inherited
gets()
gets() : string
Returns a line from the file pointer

Returns

string
Inherited
getss()
getss($allowable_tags = null) : string
Returns a line from the file pointer and strips HTML tags

Parameters

$allowable_tags

No description

Returns

string
Inherited
has_contents()
has_contents()
Inherited
isEncrypted()
isEncrypted() : boolean
Check if a file is encrypted using the built-in Hazaar encryption method

Returns

boolean
Inherited
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.

Returns

boolean
Inherited
is_dir()
is_dir()
Inherited
is_file()
is_file()
Inherited
is_link()
is_link()
Inherited
is_readable()
is_readable()
Inherited
is_writable()
is_writable()
Inherited
lock()
lock($operation, $wouldblock = null) : boolean
Portable advisory file locking

Parameters

$operationmixed

operation is one of the following: LOCK_SH to acquire a shared lock (reader). LOCK_EX to acquire an exclusive lock (writer). LOCK_UN to release a lock (shared or exclusive). It is also possible to add LOCK_NB as a bitmask to one of the above operations if you don’t want flock() to block while locking.

$wouldblockmixed

The optional third argument is set to 1 if the lock would block (EWOULDBLOCK errno condition).

Returns

boolean
Inherited
md5()
md5() : string
Generate an MD5 checksum of the current file content

Returns

string
Inherited
media_uri()
media_uri()
Inherited
mime_content_type()
mime_content_type()
Inherited
moveTo()
moveTo($destination, $create_dest = false, $dstBackend = null)

Parameters

$destination

No description

$create_dest

No description

$dstBackend

No description

Inherited
mtime()
mtime()
Inherited
name()
name()
Inherited
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.

Parameters

$modestring

No description

Returns

resource
Inherited
parent()
parent()
Inherited
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.

Parameters

$assocmixed

Return as an associative array. Default is to use stdClass.

Returns

mixed
Inherited
preview_uri()
preview_uri($params = Array ( ) )

Parameters

$params

No description

Inherited
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.

Parameters

$datamixed

The data to write

$overwritemixed

Overwrite data if it exists

Inherited
putcsv()
putcsv($fields, $delimiter = ',', $enclosure = '"', $escape = '\\') : \integer|null
Writes an array to the file in CSV format.

Parameters

$fieldsmixed

Must be greater than the longest line (in characters) to be found in the CSV file (allowing for trailing line-end characters). Otherwise the line is split in chunks of length characters, unless the split would occur inside an enclosure.

Omitting this parameter (or setting it to 0 in PHP 5.1.0 and later) the maximum line length is not limited, which is slightly slower.
$delimitermixed

The optional delimiter parameter sets the field delimiter (one character only).

$enclosuremixed

The optional enclosure parameter sets the field enclosure character (one character only).

$escapemixed

The optional escape parameter sets the escape character (one character only).

Returns

\integer|null
Inherited
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.

Parameters

$lengthmixed

Up to length number of bytes read.

Returns

\boolean|string
Inherited
readCSV()
readCSV() : array
Return the CSV content as a parsed array

Returns

array
Inherited
realpath()
realpath()
Inherited
rename()
rename($newname) : boolean
Renames a file or directory

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

Parameters

$newnamemixed

The new name.

Returns

boolean
Inherited
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.

Returns

mixed
Inherited
saveAs()
saveAs($filename, $overwrite = false) : mixed
Saves this file objects content to another file name.

Parameters

$filenamemixed

The filename to save as

$overwritemixed

Boolean flag to indicate that the destination should be overwritten if it exists

Returns

mixed
Inherited
seek()
seek($offset, $whence = 'seek_set') : \boolean|integer
Seeks to a position in the file

Parameters

$offsetmixed

The offset. To move to a position before the end-of-file, you need to pass a negative value in offset and set whence to SEEK_END.

$whencemixed

whence values are: 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.

Returns

\boolean|integer
Inherited
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.

Parameters

$bytesmixed

The data to set as the content

Inherited
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.

Parameters

$bytesmixed

The encoded data

Inherited
set_meta()
set_meta($values)

Parameters

$values

No description

Inherited
set_mime_content_type()
set_mime_content_type($type)

Parameters

$type

No description

Inherited
size()
size()
Inherited
tell()
tell() : \boolean|integer
Returns the current position of the file read/write pointer
Inherited
thumbnail()
thumbnail($params = Array ( ) )

Parameters

$params

No description

Inherited
toArray()
toArray($delimiter = '"\n"')

Parameters

$delimiter

No description

Inherited
toString()
toString()
Inherited
truncate()
truncate($size) : boolean
Truncates a file to a given length

Parameters

$sizemixed

The size to truncate to.

Returns

boolean
Inherited
type()
type()
Inherited
unlink()
unlink() : mixed
Deletes the file from storage

Returns

mixed
Inherited
unzip()
unzip($filenames = null, $target = null)

Parameters

$filenames

No description

$target

No description

Inherited
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.

Parameters

$stringmixed

The string that is to be written.

$lengthmixed

If the length argument is given, writing will stop after length bytes have been written or the end of string is reached, whichever comes first.

Note that if the length argument is given, then the magic_quotes_runtime configuration option will be ignored and no slashes will be stripped from string.

Returns

\boolean|integer
Inherited
ziplist()
ziplist()