Class File

File helper.

Functions useful for working with files and directories.

Used as follows:

$file = Core::make('helper/file');
$path = 'http://www.concrete5.org/tools/get_latest_version_number';
$contents = $file->getContents($path);
echo $contents;
Namespace: Concrete\Core\File\Service
Package: Helpers
Category: Concrete
Copyright: Copyright (c) 2003-2008 Concrete5. (http://www.concrete5.org)
License: MIT License
Author: Andrew Embler andrew@concrete5.org
Located at src/File/Service/File.php

Methods summary

public array
# getDirectoryContents( string $dir, array $ignoreFilesArray = array(), boolean $recursive = false )

Returns the contents of a directory.

public string
# unfilename( string $filename )

Removes the extension of a filename, uncamelcases it.

public
# copyAll( string $source, string $target, integer $mode = null )

Recursively copies all items in the source directory or file to the target directory.

public stdClass
# getCreateFilePermissions( string $path = null )

Returns an object with two permissions modes (octal): one for files: $res->file and another for directories: $res->dir.

public boolean
# removeAll( string $source, boolean $inc = false )

Removes all files from within a specified directory.

public
# forceDownload( stings $file )

Takes a path to a file and sends it to the browser, streaming it, and closing the HTTP connection afterwards. Basically a force download method.

public string
# getTemporaryDirectory( )

Returns the full path to the temporary directory.

public boolean
# append( string $filename, string $content )

Adds content to a new line in a file. If a file is not there it will be created.

public string|boolean
# getContents( string $file, string $timeout = null )

Just a consistency wrapper for file_get_contents Should use curl if it exists and fopen isn't allowed (thanks Remo).

public boolean
# clear( $file )

Removes contents of the file.

public string
# sanitize( string $file )

Cleans up a filename and returns the cleaned up version.

public array
# splitFilename( string $filename )

Splits a filename into directory, base file name, extension. If the file name starts with a dot and it's the only dot (eg: '.htaccess'), we don't consider the file to have an extension.

public string
# getExtension( string $filename )

Returns the extension for a file name.

public string
# replaceExtension( string $filename, string $extension )

Takes a path and replaces the files extension in that path with the specified extension.

public boolean
# isSamePath( string $path1, string $path2 )

Checks if two path are the same, considering directory separator and OS case sensitivity.