jFile

A class helper to read or create files

package

jelix

subpackage

utils

Methods

copy the whole content of a directory into an other

copyDirectoryContent(string $sourcePath, string $targetPath,  $overwrite = false) 
static
since 1.6.19

Arguments

$sourcePath

string

the path of the directory content. It does not create the directory itself into the target directory.

$targetPath

string

the full path of the directory to where to copy the content. The directory is created if it does not exists.

$overwrite

create a directory It creates also all necessary parent directory

createDir(string $dir,  $chmod = null) 
static

Arguments

$dir

string

the path of the directory

$chmod

get the MIME Type of a file

getMimeType(string $file) : string
static
since 1.1.6

Arguments

$file

string

The full path of the file

Response

string

the MIME type of the file

get the MIME Type of a file, only with its name

getMimeTypeFromFilename(string $fileName) : string
static
since 1.1.10

Arguments

$fileName

string

the file name

Response

string

the MIME type of the file

parse a path replacing Jelix shortcuts parts (var:, temp:, www:, app:, lib:)

parseJelixPath(string $path) : string
static

Arguments

$path

string

the path with parts to replace

Response

string

the path which is a system valid path

Reads the content of a file.

read(string $filename) : string
static

Arguments

$filename

string

the filename we're gonna read

Response

string

the content of the file. false if cannot read the file

Recursive function deleting a directory

removeDir(string $path, boolean $deleteParent = true, array $except = array()) : boolean
static
since 1.0b1
author

Loic Mathaud

Throws
\jException

Arguments

$path

string

The path of the directory to remove recursively

$deleteParent

boolean

If the path must be deleted too

$except

array

filenames and suffix of filename, for files to NOT delete

Response

boolean

true if all the content has been removed

replace a path with Jelix shortcuts parts (var:, temp:, www: app:, lib:)

unparseJelixPath(string $path, string $beforeShortcut = '', string $afterShortcut = '') : string
static

Arguments

$path

string

the system valid path

$beforeShortcut

string

a string to be output before the Jelix shortcut

$afterShortcut

string

a string to be output after the Jelix shortcut

Response

string

the path with Jelix shortcuts parts

Write a file to the disk.

write( $file,  $data,  $chmod = null) 
static

This function is heavily based on the way smarty process its own files. Is using a temporary file and then rename the file. We guess the file system will be smarter than us, avoiding a writing / reading while renaming the file. This method comes from CopixFile class of Copix framework

author

Gérald Croes

copyright

2001-2005 CopixTeam

link

http://www.copix.org

Arguments

$file

$data

$chmod

Properties

mimeTypes

mimeTypes : 
static

Type(s)