include/utils/sugar_file_utils.php
Functions
get_mode(
$key
=
'dir_mode', int $mode
=
null
)
:
int
get_mode
Will check to see if there is a default mode defined in the config file, otherwise return the $mode given as input
Name | Type | Description |
---|---|---|
$key | ||
$mode | int |
|
Type | Description |
---|---|
int | - the mode either found in the config file or passed in via the input parameter |
sugar_cached(
string $file
)
:
void
Get filename in cache directory
Name | Type | Description |
---|---|---|
$file | string |
- Api
sugar_chgrp(
\filename $filename, \group $group
=
''
)
:
boolean
sugar_chgrp Attempts to change the group of the file filename to the group specified in the default_permissions configuration; otherwise it will use the group value.
Name | Type | Description |
---|---|---|
$filename | \filename |
|
$group | \group |
|
Type | Description |
---|---|
boolean | - Returns TRUE on success or FALSE on failure. |
sugar_chmod(
string $filename, int $mode
=
null
)
:
boolean
sugar_chmod Attempts to change the permission of the specified filename to the mode value specified in the default_permissions configuration; otherwise, it will use the mode value.
Name | Type | Description |
---|---|---|
$filename | string | filename - Path to the file |
$mode | int | The integer value of the permissions mode to set the created directory to |
Type | Description |
---|---|
boolean | Returns TRUE on success or FALSE on failure. |
sugar_chown(
\filename $filename, \user $user
=
''
)
:
boolean
sugar_chown Attempts to change the owner of the file filename to the user specified in the default_permissions configuration; otherwise, it will use the user value.
Name | Type | Description |
---|---|---|
$filename | \filename |
|
$user | \user |
|
Type | Description |
---|---|
boolean | - Returns TRUE on success or FALSE on failure. |
sugar_file_get_contents(
\$filename $filename, \$use_include_path $use_include_path
=
false, $context
=
null
)
:
string | boolean
sugar_file_get_contents
Name | Type | Description |
---|---|---|
$filename | \$filename |
|
$use_include_path | \$use_include_path |
|
$context |
Type | Description |
---|---|
string | boolean | - Returns a file data on success, false otherwise |
sugar_file_put_contents(
\$filename $filename, \$data $data, \$flags $flags
=
null, $context
=
null
)
:
int
sugar_file_put_contents Call this function instead of file_put_contents to apply preconfigured permission settings when creating the the file. This method is basically a wrapper to the PHP file_put_contents function except that it supports setting the mode value by using the configuration file (if set). The mode is 0777 by default.
Name | Type | Description |
---|---|---|
$filename | \$filename |
|
$data | \$data |
|
$flags | \$flags |
|
$context |
Type | Description |
---|---|
int | - Returns the number of bytes written to the file, false otherwise. |
sugar_file_put_contents_atomic(
\$filename $filename, \$data $data, string $mode
=
'wb', boolean $use_include_path
=
false, \context $context
=
null
)
:
boolean
sugar_file_put_contents_atomic This is an atomic version of sugar_file_put_contents. It attempts to circumvent the shortcomings of file_put_contents by creating a temporary unique file and then doing an atomic rename operation.
Name | Type | Description |
---|---|---|
$filename | \$filename |
|
$data | \$data |
|
$mode | string | String value of the parameter to specify the type of access you require to the file stream |
$use_include_path | boolean | set to '1' or TRUE if you want to search for the file in the include_path too |
$context | \context | Context to pass into fopen operation |
Type | Description |
---|---|
boolean | - Returns true if $filename was created, false otherwise. |
sugar_fopen(
\$filename $filename, \$mode $mode, \$$use_include_path $use_include_path
=
false, $context
=
null
)
:
boolean
sugar_fopen Call this function instead of fopen to apply preconfigured permission settings when creating the the file. This method is basically a wrapper to the PHP fopen function except that it supports setting the mode value by using the configuration file (if set). The mode is 0777 by default.
Name | Type | Description |
---|---|---|
$filename | \$filename |
|
$mode | \$mode |
|
$use_include_path | \$$use_include_path |
|
$context |
Type | Description |
---|---|
boolean | - Returns a file pointer on success, false otherwise |
sugar_mkdir(
\$pathname $pathname, \$mode $mode
=
null, \$recursive $recursive
=
false, $context
=
''
)
:
boolean
sugar_mkdir Call this function instead of mkdir to apply preconfigured permission settings when creating the directory. This method is basically a wrapper to the PHP mkdir function except that it supports setting the mode value by using the configuration file (if set). The mode is 0777 by default.
Name | Type | Description |
---|---|---|
$pathname | \$pathname |
|
$mode | \$mode |
|
$recursive | \$recursive |
|
$context |
Type | Description |
---|---|
boolean | - Returns true on success false on failure |
sugar_touch(
\$filename $filename, \$time $time
=
null, \$atime $atime
=
null
)
:
boolean
sugar_touch Attempts to set the access and modification times of the file named in the filename parameter to the value given in time . Note that the access time is always modified, regardless of the number of parameters. If the file does not exist it will be created.
This method is basically a wrapper to the PHP touch method except that created files may be set with the permissions specified in the configuration file (if set).
Name | Type | Description |
---|---|---|
$filename | \$filename |
|
$time | \$time |
|
$atime | \$atime |
|
Type | Description |
---|---|
boolean | - Returns TRUE on success or FALSE on failure. |