include/utils/sugar_file_utils.php

Show: inherited
    Table of Contents

    Functions

    functionget_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

    Parameters
    Name Type Description
    $key
    $mode int
    • the mode being passed by the calling function. This value will be overridden by a value defined in the config file.
    Returns
    Type Description
    int - the mode either found in the config file or passed in via the input parameter
    functionsugar_cached( string $file ) : void

    Get filename in cache directory

    Parameters
    Name Type Description
    $file string
    Details
    Api
     
    functionsugar_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.

    Parameters
    Name Type Description
    $filename \filename
    • Path to the file
    $group \group
    • A group name or number
    Returns
    Type Description
    boolean - Returns TRUE on success or FALSE on failure.
    functionsugar_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.

    Parameters
    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

    Returns
    Type Description
    boolean Returns TRUE on success or FALSE on failure.
    functionsugar_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.

    Parameters
    Name Type Description
    $filename \filename
    • Path to the file
    $user \user
    • A user name or number
    Returns
    Type Description
    boolean - Returns TRUE on success or FALSE on failure.
    functionsugar_file_get_contents( \$filename $filename, \$use_include_path $use_include_path = false,  $context = null ) : string | boolean

    sugar_file_get_contents

    Parameters
    Name Type Description
    $filename \$filename
    • String value of the file to create
    $use_include_path \$use_include_path
    • boolean value indicating whether or not to search the the included_path
    $context
    Returns
    Type Description
    string | boolean - Returns a file data on success, false otherwise
    functionsugar_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.

    Parameters
    Name Type Description
    $filename \$filename
    • String value of the file to create
    $data \$data
    • The data to be written to the file
    $flags \$flags
    • int as specifed by file_put_contents parameters
    $context
    Returns
    Type Description
    int - Returns the number of bytes written to the file, false otherwise.
    functionsugar_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.

    Parameters
    Name Type Description
    $filename \$filename
    • String value of the file to create
    $data \$data
    • The data to be written to the file
    $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

    Returns
    Type Description
    boolean - Returns true if $filename was created, false otherwise.
    functionsugar_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.

    Parameters
    Name Type Description
    $filename \$filename
    • String value of the file to create
    $mode \$mode
    • The integer value of the permissions mode to set the created file to
    $use_include_path \$$use_include_path
    • boolean value indicating whether or not to search the the included_path
    $context
    Returns
    Type Description
    boolean - Returns a file pointer on success, false otherwise
    functionsugar_is_dir(  $path,  $mode = 'r' ) : void

    Parameters
    Name Type Description
    $path
    $mode
    functionsugar_is_file(  $path,  $mode = 'r' ) : void

    Parameters
    Name Type Description
    $path
    $mode
    functionsugar_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.

    Parameters
    Name Type Description
    $pathname \$pathname
    • String value of the directory to create
    $mode \$mode
    • The integer value of the permissions mode to set the created directory to
    $recursive \$recursive
    • boolean value indicating whether or not to create recursive directories if needed
    $context
    Returns
    Type Description
    boolean - Returns true on success false on failure
    functionsugar_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).

    Parameters
    Name Type Description
    $filename \$filename
    • The name of the file being touched.
    $time \$time
    • The touch time. If time is not supplied, the current system time is used.
    $atime \$atime
    • If present, the access time of the given filename is set to the value of atime
    Returns
    Type Description
    boolean - Returns TRUE on success or FALSE on failure.
    Documentation was generated by DocBlox 0.18.1.