Jelix 1.6.37

jFile
in package

A class helper to read or create files

Tags
subpackage

utils

Table of Contents

$mimeTypes  : mixed
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
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
unparseJelixPath()  : string
replace a path with Jelix shortcuts parts (var:, temp:, www: app:, lib:)
write()  : mixed
Write a file to the disk.

Properties

$mimeTypes

protected static mixed $mimeTypes = array( 'txt' => 'text/plain', 'htm' => 'text/html', 'html' => 'text/html', 'xhtml' => 'application/xhtml+xml', 'xht' => 'application/xhtml+xml', 'php' => 'text/html', 'css' => 'text/css', 'js' => 'application/javascript', 'json' => 'application/json', 'xml' => 'application/xml', 'xslt' => 'application/xslt+xml', 'xsl' => 'application/xml', 'dtd' => 'application/xml-dtd', 'atom' => 'application/atom+xml', 'mathml' => 'application/mathml+xml', 'rdf' => 'application/rdf+xml', 'smi' => 'application/smil', 'smil' => 'application/smil', 'vxml' => 'application/voicexml+xml', 'latex' => 'application/x-latex', 'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex', 'texinfo' => 'application/x-texinfo', 'wrl' => 'model/vrml', 'wrml' => 'model/vrml', 'ics' => 'text/calendar', 'ifb' => 'text/calendar', 'sgml' => 'text/sgml', 'htc' => 'text/x-component', // images 'png' => 'image/png', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'bmp' => 'image/bmp', 'ico' => 'image/x-icon', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'svg' => 'image/svg+xml', 'svgz' => 'image/svg+xml', 'djvu' => 'image/vnd.djvu', 'djv' => 'image/vnd.djvu', // archives 'zip' => 'application/zip', 'rar' => 'application/x-rar-compressed', 'exe' => 'application/x-msdownload', 'msi' => 'application/x-msdownload', 'cab' => 'application/vnd.ms-cab-compressed', 'tar' => 'application/x-tar', 'gz' => 'application/x-gzip', 'tgz' => 'application/x-gzip', // audio/video 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mpe' => 'video/mpeg', 'wav' => 'audio/wav', 'aiff' => 'audio/aiff', 'aif' => 'audio/aiff', 'avi' => 'video/msvideo', 'wmv' => 'video/x-ms-wmv', 'ogg' => 'application/ogg', 'flv' => 'video/x-flv', 'dvi' => 'application/x-dvi', 'au' => 'audio/basic', 'snd' => 'audio/basic', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'm3u' => 'audio/x-mpegurl', 'm4u' => 'video/vnd.mpegurl', 'ram' => 'audio/x-pn-realaudio', 'ra' => 'audio/x-pn-realaudio', 'rm' => 'application/vnd.rn-realmedia', // adobe 'pdf' => 'application/pdf', 'psd' => 'image/vnd.adobe.photoshop', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'swf' => 'application/x-shockwave-flash', // ms office 'doc' => 'application/msword', 'docx' => 'application/msword', 'rtf' => 'application/rtf', 'xls' => 'application/vnd.ms-excel', 'xlm' => 'application/vnd.ms-excel', 'xla' => 'application/vnd.ms-excel', 'xld' => 'application/vnd.ms-excel', 'xlt' => 'application/vnd.ms-excel', 'xlc' => 'application/vnd.ms-excel', 'xlw' => 'application/vnd.ms-excel', 'xll' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'pps' => 'application/vnd.ms-powerpoint', // open office 'odt' => 'application/vnd.oasis.opendocument.text', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', )

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[, mixed $chmod = null ]) : mixed
Parameters
$dir : string

the path of the directory

$chmod : 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
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

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

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[, 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 : mixed = null
Tags
author

Gérald Croes

copyright

2001-2005 CopixTeam

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

Search results