File
File
Properties
source_file
public string $source_file
default_cipher
public string $default_cipher
default_key
public string $default_key
manager
protected Manager $manager
info
protected array $info
mimeContentType
public string $mimeContentType
contents
Any overridden file contents.
protected string $contents
This is normally used when performing operations on the file in memory, such as resizing an image.
csv_contents
public array $csv_contents
resource
protected mixed $resource
relative_path
protected string $relative_path
stream
private mixed $stream
encrypted
private bool $encrypted
__media_url
public URL $__media_url
filters
Content filters.
private array $filters
Methods
__construct
public __construct({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$file | mixed | |
$manager | Manager | |
$relative_path | string |
__toString
public __toString({Array})
backend
public backend({Array})
getManager
public getManager({Array})
get
public get({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$url | string | |
$client | Client |
registerFilter
Content filters.
public registerFilter({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$type | int | |
$callable | string |
setMeta
public setMeta({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$values | array |
getMeta
public getMeta({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$key | string |
toString
public toString({Array})
basename
public basename({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$suffix | string |
dirname
public dirname({Array})
name
public name({Array})
fullpath
public fullpath({Array})
relativepath
Get the relative path of the file.
public relativepath({Array})
If the file was returned from a [[Hazaar\File\Dir]] object, then it will have a stored relative path. Otherwise any file/path can be provided in the form of another [[Hazaar\File\ object, [[Hazaar\File\Dir]] object, or string path, and the relative path to the file will be returned.
Parameters
Parameter | Type | Description |
---|---|---|
$path | NULL | optional path to use as the relative path |
setRelativePath
public setRelativePath({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$path | string |
extension
public extension({Array})
size
public size({Array})
exists
public exists({Array})
realpath
public realpath({Array})
isReadable
public isReadable({Array})
isWritable
public isWritable({Array})
isFile
public isFile({Array})
isDir
public isDir({Array})
isLink
public isLink({Array})
dir
public dir({Array})
parent
public parent({Array})
type
public type({Array})
ctime
public ctime({Array})
mtime
public mtime({Array})
touch
public touch({Array})
atime
public atime({Array})
hasContents
public hasContents({Array})
getContents
Returns the current contents of the file.
public getContents({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$offset | int | |
$maxlen | int |
putContents
Put contents directly writes data to the storage backend without storing it in the file object itself.
public putContents({Array})
NOTE: This function is called internally to save data that has been updated in the file object.
Parameters
Parameter | Type | Description |
---|---|---|
$data | string | The data to write |
$overwrite | bool | Overwrite data if it exists |
setContents
Sets the current contents of the file in memory.
public setContents({Array})
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
Parameter | Type | Description |
---|---|---|
$bytes | string | The data to set as the content |
setDecodedContents
Set the contents from an encoded string.
public setDecodedContents({Array})
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
Parameter | Type | Description |
---|---|---|
$bytes | string |
getEncodedContents
Return the contents of the file as a data URI encoded string.
public getEncodedContents({Array})
This function is basically the opposite of Hazaar\File::set_decoded_contents() and will generate a data URI based on the current MIME content type and the contents of the file.
save
Saves the current in-memory content to the storage backend.
public save({Array})
Internally this calls File::putContents() to write the data to the backend.
saveAs
Saves this file objects content to another file name.
public saveAs({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$filename | string | The filename to save as |
$overwrite | bool | Boolean flag to indicate that the destination should be overwritten if it exists |
unlink
Deletes the file from storage.
public unlink({Array})
md5
Generate an MD5 checksum of the current file content.
public md5({Array})
base64
Return the base64 encoded content.
public base64({Array})
parseJSON
Returns the contents as decoded JSON.
public parseJSON({Array})
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
Parameter | Type | Description |
---|---|---|
$assoc | bool | Return as an associative array. Default is to use stdClass. |
$ | \stdClass |
moveTo
public moveTo({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$destination | string | |
$overwrite | bool | |
$create_dest | bool | |
$dstManager | Manager |
copyTo
Copy the file to another folder.
public copyTo({Array})
This differs to copy() which expects the target to be the full new file pathname.
Parameters
Parameter | Type | Description |
---|---|---|
$destination | string | The destination folder to copy the file into |
$overwrite | bool | overwrite the destination file if it exists |
$create_dest | bool | Flag that indicates if the destination folder should be created. If the |
destination does not exist an error will be thrown. |
| $dstManager
| Manager
| The destination file manager. Defaults to the same manager as the source. |
copy
Copy the file to another folder and filename.
public copy({Array})
This differs from copyTo which expects the target to be a folder
Parameters
Parameter | Type | Description |
---|---|---|
$destination | string | The destination folder and file name to copy the file into |
$overwrite | boolean | overwrite the destination file if it exists |
$create_dest | boolean | Flag that indicates if the destination folder should be created. If the |
destination does not exist an error will be thrown. |
| $dstManager
| NULL
| The destination file manager. Defaults to the same manager as the source. |
mimeContentType
public mimeContentType({Array})
setMimeContentType
public setMimeContentType({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$type | string |
thumbnailURL
public thumbnailURL({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$width | int | |
$height | int | |
$format | string | |
$params | array |
previewURL
public previewURL({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$params | array |
directURL
public directURL({Array})
mediaURL
public mediaURL({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$set_path | URL |
toArray
public toArray({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$delimiter | string |
readCSV
Return the CSV content as a parsed array.
public readCSV({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$use_header_row | bool | Indicates if a header row should be parsed and used to build an associative array. In this case the |
keys in the returned array will be the values from the first row, which is normally a header row. |
getcsv
Returns a line from the file pointer and parse for CSV fields.
public getcsv({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$length | int | 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. |
| $delimiter
| string
| the optional delimiter parameter sets the field delimiter (one character only) | | $enclosure
| string
| the optional enclosure parameter sets the field enclosure character (one character only) | | $escape
| string
| the optional escape parameter sets the escape character (one character only) |
putcsv
Writes an array to the file in CSV format.
public putcsv({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$fields | array | 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. |
| $delimiter
| string
| the optional delimiter parameter sets the field delimiter (one character only) | | $enclosure
| string
| the optional enclosure parameter sets the field enclosure character (one character only) | | $escape
| string
| the optional escape parameter sets the escape character (one character only) |
rename
Renames a file or directory.
public rename({Array})
NOTE: This will not work if the file is currently opened by another process.
Parameters
Parameter | Type | Description |
---|---|---|
$newname | string | The new name. Must not be an absolute/relative path. If you want to move the file use File::moveTo(). |
delete
public delete({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$path | string |
jsonSerialize
public jsonSerialize({Array})
perms
public perms({Array})
chmod
public chmod({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$mode | int |
isEncrypted
Check if a file is encrypted using the built-in Hazaar encryption method.
public isEncrypted({Array})
encrypt
public encrypt({Array})
decrypt
public decrypt({Array})
isOpen
public isOpen({Array})
open
public open({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$mode | string |
read
public read({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$length | int |
write
public write({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$bytes | string | |
$length | int |
seek
public seek({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$offset | int | |
$whence | int |
tell
public tell({Array})
eof
public eof({Array})
truncate
public truncate({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$size | int |
lock
public lock({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$operation | int | |
$wouldblock | int |
flush
public flush({Array})
gets
public gets({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$length | int |
close
public close({Array})
filterIn
Internal content filter.
protected filterIn({Array})
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.
Parameters
Parameter | Type | Description |
---|---|---|
$content | string |
filterOut
Internal content filter.
protected filterOut({Array})
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.
Parameters
Parameter | Type | Description |
---|---|---|
$content | string |
getEncryptionKey
private getEncryptionKey({Array})
Generated by Hazaar API Doc Generator