Trait FileTrait
Provides a set of methods to represent a file.
Traits provide extended method support to classes without requiring a direct, linear chain of inheritance. This allows functions to inherit subsets of related methods without declaring a parent class.
In Oroboros core, ALL methods are granted to classes via traits, and the classes themselves are just containers that correlate their methods to an interface they are expected to honor. This approach maximizes interoperability, by entirely removing class inheritance as a requirement for extension of any class in this system.
3rd parties using this package are not expected to follow this approach,
but ALL of our internal class and logic structure does.
Direct Known Users
oroboros\core\abstracts\libraries\file\AbstractFile
,
oroboros\core\traits\libraries\file\UploadedFileTrait
Indirect Known Users
Package: oroboros\core\file
Category: contract-interfaces
License: The MIT License (MIT)
Author: Brian Dayhoff mopsyd@me.com
Version: 0.2.4
Since: 0.2.4-alpha
Link: bitbucket.org/oroborosframework/oroboros-core/wiki/development/api/contract_interface.md
Located at core/traits/libraries/file/FileTrait.php
Methods summary
public
|
#
__construct( string $file = null, $type = null, $temp_alias = null )
|
protected
|
#
_initializeFileObject( string $file = null, string $type = null, string $temp_alias = null )
|
protected
|
#
_setFileType( string $type = 'bin' )
|
protected
string|null
|
#
_getFileExtension( )
|
protected
string
|
|
protected
string|boolean
|
#
_getFileInfoLink( )
|
protected
string|boolean
|
|
protected
string
|
|
protected
string
|
|
protected
|
|
protected
integer
|
|
protected
boolean
|
|
protected
boolean
|
|
protected
boolean
|
|
protected
boolean
|
|
protected
boolean
|
#
_fileIsInitialized( )
|
private
|
|
private
|
|
private
|
#
_setFileTempAliasValue( string $value = null )
Sets the supplied temp alias value, if the file is a temp file. |
private
|
|
private
|
|
private
|
|
private
|
|
private
|
|
private
|
#
_setFileReadableValue( )
Sets a boolean determination as to whether the file is readable by the server in the scope of the current runtime. |
private
|
#
_setFileWriteableValue( )
Sets a boolean determination as to whether the file is writeable by the server in the scope of the current runtime. |
private
resource|false
|
#
_getFileStreamResource( string $mode = 'r' )
Returns a file pointer resource to the file, or false on failure. This method takes the standard fopen valid mode parameters for it's $mode input. |
private
|
#
_moveFileTo( type $new_directory, type $new_filename = null )
Moves the file to a new location. If the same file exists in the new location, it will be replaced. |
private
|
#
_copyFileTo( type $new_directory, type $new_filename = null )
Creates a copy of the file in the specified location. If the same file exists in the new location, it will be replaced. |
private
|
#
_deleteFile( )
Deletes the file, if it exists. In most cases, this will render this object unuseable, and it should be unset after this is called. |
private
|
|
private
|
#
_touchFile( )
Updates the files 'last modified' property to the current time, as defined by the server. |
private
|
#
_setFileContents( type $content, type $truncate = false, type $append = true )
Sets the file contents. |
private
|
Properties summary
private static
array
|
$_file_extension_information
Represents a catalog of known file extensions, and can return their extension, mime type, human-readable title, and an information url as to what they do. This is based on a information dictionary provided with the system. |
#
false
|
private
string
|
$_file_path
Represents the directory path to the file |
#
null
|
private
string
|
$_file_name
Represents the name of the file |
#
null
|
private
boolean
|
$_file_exists
Represents whether or not the file actually exists. |
#
false
|
private
integer
|
$_file_size
Represents the size in bytes of the file |
#
0
|
private
string
|
$_file_extension
Represents the file type, as defined by it's suffix. This may not represent the literal file type, if it is accidentally or intentionally misnamed. The default is binary if this cannot be determined. |
#
null
|
private
string
|
$_file_encoding
Represents the encoding of the file. The default is binary if this cannot be determined. |
#
null
|
private
string
|
$_file_mime
Represents the mime type for http transit. The default is binary if this cannot be determined. |
#
null
|
private
string|boolean
|
$_file_type_info
Represents a link to external documentation about the file type. The default is false if this cannot be determined. |
#
null
|
private
boolean
|
$_file_readable
Represents whether the file is readable by the server or not, within the scope of the current runtime. Note that this may differ between http and cli execution. |
#
false
|
private
boolean
|
$_file_writeable
Represents whether the file is writeable by the server or not, within the scope of the current runtime. Note that this may differ between http and cli execution. |
#
false
|
private
boolean
|
$_file_is_temp
Represents a boolean determination as to whether the file is a temp file or not. This is based off of the system defined temp directory, and will not automatically pick up whether or not the file exists in a custom temp directory not known to the server. |
#
false
|
private
string|boolean
|
$_file_temp_alias
Represents the desired name of the file, if it was uploaded as a temporary file. The file will be automatically renamed to this name if it is moved from the temp directory, if another name for it is not provided. This is to retain upload names, which do not always correspond to temp save names. |
#
false
|
private
boolean
|
$_file_is_initialized
Determines whether or not the file object wrapper has been initialized. |
#
false
|