include/utils/file_utils.php

Show: inherited
    Table of Contents

    Functions

    functioncleanDirName( string $name ) : string

    Filter dir name to not contain path components - no slashes, no .., etc.

    Parameters
    Name Type Description
    $name string
    Returns
    Type Description
    string
    functioncleanFileName(  $name ) : void

    Parameters
    Name Type Description
    $name
    functionclean_path( string $path ) : string

    Convert all \ to / in path, remove multiple '/'s and '/./'

    Parameters
    Name Type Description
    $path string
    Returns
    Type Description
    string
    functioncreateFTSLogicHook(  $filePath = 'application/Ext/LogicHooks/logichooks.ext.php' ) : void

    Parameters
    Name Type Description
    $filePath
    functioncreate_cache_directory(  $file ) : void

    Parameters
    Name Type Description
    $file
    functioncreate_custom_directory(  $file ) : void

    Parameters
    Name Type Description
    $file
    functionfileToHash(  $file ) : void

    Parameters
    Name Type Description
    $file
    functiongenerateMD5array( \$path $path, \$ignore_dirs $ignore_dirs = array('cache', 'upload') ) : void

    This function will recursively generates md5s of files and returns an array of all md5s.

    Parameters
    Name Type Description
    $path \$path

    The path of the root directory to scan - must end with '/'

    $ignore_dirs \$ignore_dirs

    array of filenames/directory names to ignore running md5 on - default 'cache' and 'upload'

    Details
    Result
    $md5_array an array containing path as key and md5 as value  
    functiongetFiles( array $arr, string $dir, \regex $pattern = null ) : void

    Function to retrieve all file names of matching pattern in a directory (and it's subdirectories) example: getFiles($arr, './modules', '.+/EditView.php/'); // grabs all EditView.phps

    Parameters
    Name Type Description
    $arr array

    return array to populate matches

    $dir string

    directory to look in [ USE ./ in front of the $dir! ]

    $pattern \regex

    optional pattern to match against

    functionget_file_extension( \$filename $filename, \$string_to_lower $string_to_lower = true ) : \extension

    get_file_extension This function returns the file extension portion of a given filename

    Parameters
    Name Type Description
    $filename \$filename

    String of filename to return extension

    $string_to_lower \$string_to_lower

    boolean value indicating whether or not to return value as lowercase, true by default

    Returns
    Type Description
    \extension String value, blank if no extension found
    functionget_mime_content_type_from_filename( \$filename $filename ) : \mime

    get_mime_content_type_from_filename This function is similar to mime_content_type, but does not require a real file or path location. Instead, the function merely checks the filename extension and returns a best guess mime content type.

    Parameters
    Name Type Description
    $filename \$filename

    String of filename to return mime content type

    Returns
    Type Description
    \mime content type as String value (defaults to 'application/octet-stream' for filenames with extension, empty otherwise)
    functionget_module_dir_list( ) : void

    functionhashToFile(  $hash ) : void

    Parameters
    Name Type Description
    $hash
    functionmd5DirCompare( \$path_a $path_a, \$path_b $path_b, \$ignore_dirs $ignore_dirs = array('cache', 'upload') ) : void

    Function to compare two directory structures and return the items in path_a that didn't match in path_b

    Parameters
    Name Type Description
    $path_a \$path_a

    The path of the first root directory to scan - must end with '/'

    $path_b \$path_b

    The path of the second root directory to scan - must end with '/'

    $ignore_dirs \$ignore_dirs

    array of filenames/directory names to ignore running md5 on - default 'cache' and 'upload'

    Details
    Result
    array containing all the md5s of everything in $path_a that didn't have a match in $path_b  
    functionmk_temp_dir(  $base_dir,  $prefix = "" ) : void

    Parameters
    Name Type Description
    $base_dir
    $prefix
    functionreadfile_chunked( string $filename, int $retbytes = true ) : void

    Function to split up large files for download used in download.php

    Parameters
    Name Type Description
    $filename string
    $retbytes int
    functionremove_file_extension(  $filename ) : void

    Parameters
    Name Type Description
    $filename
    functionsugar_rename( string $old_filename, string $new_filename ) : void

    Renames a file. If $new_file already exists, it will first unlink it and then rename it.

    used in SugarLogger.php

    Parameters
    Name Type Description
    $old_filename string
    $new_filename string
    functionwrite_array_to_file(  $the_name,  $the_array,  $the_file,  $mode = "w",  $header = '' ) : void

    Parameters
    Name Type Description
    $the_name
    $the_array
    $the_file
    $mode
    $header
    functionwrite_encoded_file(  $soap_result,  $write_to_dir,  $write_to_file = "" ) : void

    Parameters
    Name Type Description
    $soap_result
    $write_to_dir
    $write_to_file
    Documentation was generated by DocBlox 0.18.1.