copy the file to some destination
bool
copy
(
string $destFile, [bool $overwrite = true], [bool $isRecursive = false], [int $mode = 766]
)
List of parameters:
Name |
Type |
Description |
$destFile |
string |
destination to copy the file to |
$overwrite |
bool |
setting this to false will prevent existing files from getting overwritten |
$isRecursive |
bool |
setting this to true will automatically, recursively create directories in the $destFile string, if required |
$mode |
int |
the access restriction that applies to the copied file, defaults to 0766 |
Description:
This will create a copy of this file on the filesystem. Bool(true) will be returned on success and bool(false) on error.
Possible errors are:
- the destination directory does not exist (and $isRecursive is not provided, or set to false)
- another file with the same name does already exist (and $overwrite is set to false)
- the destination file is not accessible for some other reason
If the directory the desination file would be place in does not exist, and $isRecursive is set to true, it will automatically, recursively create the missing directories. Newly created directories will be set to access restriction 0766. Note that this is unlike the default behaviour, where there is no restriction at all.
Note: instead of a file name in parameter $destFile, you may also provide the name of a directory. In this case the file the current name of the file will be used. The destination directory needs to be terminated by a forward-slash '/'.
The $destFile parameter must not be any longer than 512 characters. It must not contain any but alphanumeric characters.
If you copy a PHP file, note that for security reasons the $mode parameter defaults to 0766, which means the file will not be executable in a UNIX environment (while it may be executable on windows platforms) until you set the $mode parameter to 0777.
create the current file if it does not exist
bool
create
()
Description:
delete this file
bool
delete
()
Description:
Returns bool(true) on success and bool(false) on error.
failSafe writing of data
bool
failSafeWrite
()
Description:
Automatically restarts writing if the file-resource is temporarily not available after waiting for 0.5 seconds.
The process is aborted if it failed 3 times.
get size of this file
int
getFilesize
()
Description:
Returns the size of the file in bytes (from cached value). If an error occurs, bool(false) is returned.
insert new content
void
insert
(
scalar $text
)
List of parameters:
Name |
Type |
Description |
$text |
scalar |
|
Description:
Redefined in descendants as:
return bool(true) if file is writeable
bool
isWriteable
()
Description:
A file is "writeable" if:
- the file exists
- it is accessible
- the script has permission to write data to the file
get the number of contents inside the file
int
length
()
Description:
Redefined in descendants as:
remove an entry from the file
bool
remove
(
[string $key = ""]
)
List of parameters:
Name |
Type |
Description |
$key |
string |
(optional) |
Description:
Redefined in descendants as:
write file to system
bool
write
()
Description:
This function will return bool(true) on success. It issues an E_USER_NOTICE and returns bool(false) on error.
inherited from base classes
Inherited From FileReadonly
Inherited From FileSystemResource
Inherited From Object