Class File
Methods summary
public static
amekusa\phio\File
|
#
create( string $Path )
Creates a proper object of amekusa\phio\File subclass from a path
If the path indicates:
Parameters
Returns
Example
Passing an existing directory path, creates a amekusa\phio\Directory object
use amekusa\phio\Directory;
$dir = File::create(__DIR__);
echo 'Is $dir a directory? - ';
echo $dir instanceof Directory ? 'Yes.' : 'No.';
Is $dir a directory? - Yes.
Passing an existing regular file path or non-existent path, creates a amekusa\phio\RegFile object
use amekusa\phio\RegFile;
$file = File::create(__FILE__);
echo 'Is $file a regular file? - ';
echo $file instanceof RegFile ? 'Yes.' : 'No.';
Is $file a regular file? - Yes.
|
public static
amekusa\phio\File
|
#
instance( string $Path, boolean $ForceNew = false )
Returns a amekusa\phio\File instance associated with a specific file path
The operation is the same as amekusa\phio\File ::create($Path)
except for the returned object is cached in amekusa\phio\FilePool .
Parameters
- $Path
- The path of a file
- $ForceNew
- If
true , always returns a newly created instance of amekusa\phio\File
Returns
Example
Cache Demonstration
$X1 = File::create(__FILE__);
$Y1 = File::create(__FILE__);
$X2 = File::instance(__FILE__);
$Y2 = File::instance(__FILE__);
$X3 = File::instance(__FILE__, true);
$Y3 = File::instance(__FILE__, true);
$Z3 = File::instance(__FILE__);
echo 'Are $X1 and $Y1 identical? - ';
echo $X1 === $Y1 ? 'Yes.' : 'No.';
echo "\n";
echo 'Are $X2 and $Y2 identical? - ';
echo $X2 === $Y2 ? 'Yes.' : 'No.';
echo "\n";
echo 'Are $X3 and $Y3 identical? - ';
echo $X3 === $Y3 ? 'Yes.' : 'No.';
echo "\n";
echo 'Are $Y3 and $Z3 identical? - ';
echo $Y3 === $Z3 ? 'Yes.' : 'No.';
Are $X1 and $Y1 identical? - No.
Are $X2 and $Y2 identical? - Yes.
Are $X3 and $Y3 identical? - No.
Are $Y3 and $Z3 identical? - Yes.
|
public
|
|
public
|
|
public
|
|
public
|
|
public
boolean
|
|
public
string
|
|
public
string
|
|
public
amekusa\phio\Perms
|
|
public
integer|string
|
#
modifiedAt( string $Format = '' )
Parameters
Returns
integer|string
|
public
amekusa\phio\File
|
|
public
|
|
public
|
|
public
|
#
moveTo( string|amekusa\phio\Directory $Destination )
Moves this file to another directory
Moves this file to another directory
Parameters
- $Destination
- The directory that this file moves to
Throws
|
public
|
|