Jelix 1.7.18

jFile
in package

A class helper to read or create files.

Tags
subpackage

utils

Table of Contents

copyDirectoryContent()  : mixed
copy the whole content of a directory into an other.
createDir()  : mixed
create a directory It creates also all necessary parent directory.
getMimeType()  : string
get the MIME Type of a file.
getMimeTypeFromFilename()  : string
get the MIME Type of a file, only with its name.
normalizePath()  : string
normalize a path : translate '..', '.', replace '\' by '/' and so on.. support windows path.
parseJelixPath()  : string
parse a path replacing Jelix shortcuts parts (var:, temp:, www:, app:, lib:).
read()  : string
Reads the content of a file.
removeDir()  : bool
Recursive function deleting a directory.
shortestPath()  : string
calculate the shortest path between two directories.
unparseJelixPath()  : string
replace a path with Jelix shortcuts parts (var:, temp:, www: app:, lib:).
write()  : mixed
Write a file to the disk.

Methods

copyDirectoryContent()

copy the whole content of a directory into an other.

public static copyDirectoryContent(string $sourcePath, string $targetPath[, mixed $overwrite = false ]) : mixed
Parameters
$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 : mixed = false
Tags
since
1.6.19
Return values
mixed

createDir()

create a directory It creates also all necessary parent directory.

public static createDir(string $dir[, null|mixed $chmod = null ]) : mixed
Parameters
$dir : string

the path of the directory

$chmod : null|mixed = null
Return values
mixed

getMimeType()

get the MIME Type of a file.

public static getMimeType(string $file) : string
Parameters
$file : string

The full path of the file

Tags
since
1.1.6
deprecated

use \Jelix\FileUtilities\File::getMimeType() instead

Return values
string

the MIME type of the file

getMimeTypeFromFilename()

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

public static getMimeTypeFromFilename(string $fileName) : string
Parameters
$fileName : string

the file name

Tags
since
1.1.10
Return values
string

the MIME type of the file

normalizePath()

normalize a path : translate '..', '.', replace '\' by '/' and so on.. support windows path.

public static normalizePath(string $path) : string
Parameters
$path : string
Tags
deprecated

Use \Jelix\FileUtilities\Path::normalizePath() instead

Return values
string

the normalized path

parseJelixPath()

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

public static parseJelixPath(string $path) : string
Parameters
$path : string

the path with parts to replace

Return values
string

the path which is a system valid path

read()

Reads the content of a file.

public static read(string $filename) : string
Parameters
$filename : string

the filename we're gonna read

Return values
string

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

removeDir()

Recursive function deleting a directory.

public static removeDir(string $path[, bool $deleteParent = true ][, array<string|int, mixed> $except = array() ]) : bool
Parameters
$path : string

The path of the directory to remove recursively

$deleteParent : bool = true

If the path must be deleted too

$except : array<string|int, mixed> = array()

filenames and suffix of filename, for files to NOT delete

Tags
throws
jException
since
1.0b1
author

Loic Mathaud

Return values
bool

true if all the content has been removed

shortestPath()

calculate the shortest path between two directories.

public static shortestPath(string $from, string $to) : string
Parameters
$from : string

absolute path from which we should start

$to : string

absolute path to which we should go

Tags
deprecated

use \Jelix\FileUtilities\Path::shortestPath() instead

Return values
string

relative path between the two path

unparseJelixPath()

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

public static unparseJelixPath(string $path[, string $beforeShortcut = '' ][, string $afterShortcut = '' ]) : string
Parameters
$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

Return values
string

the path with Jelix shortcuts parts

write()

Write a file to the disk.

public static write(mixed $file, mixed $data[, null|mixed $chmod = null ]) : mixed

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.

Parameters
$file : mixed
$data : mixed
$chmod : null|mixed = null
Tags
author

Gérald Croes

copyright

2001-2005 CopixTeam

see
http://www.copix.org
Return values
mixed

Search results