Class jFile

Description

A class helper to read or create files

Located in /utils/jFile.class.php (line 23)


	
			
Variable Summary
static mixed $mimeTypes
Method Summary
static void createDir (string $dir)
static string getMimeType (string $file)
static string getMimeTypeFromFilename (string $fileName)
static string read (string $filename)
static boolean removeDir (string $path, [boolean $deleteParent = true], [array $except = array()])
static void write ( $file,  $data)
Variables
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',
)
(line 201)
  • access: protected
Methods
static createDir (line 87)

create a directory

It creates also all necessary parent directory

  • access: public
static void createDir (string $dir)
  • string $dir: the path of the directory
static getMimeType (line 167)

get the MIME Type of a file

  • return: the MIME type of the file
  • since: 1.1.6
  • access: public
static string getMimeType (string $file)
  • string $file: The full path of the file
static getMimeTypeFromFilename (line 192)

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

  • return: the MIME type of the file
  • since: 1.1.10
  • access: public
static string getMimeTypeFromFilename (string $fileName)
  • string $fileName: the file name
static read (line 29)

Reads the content of a file.

  • return: the content of the file. false if cannot read the file
  • access: public
static string read (string $filename)
  • string $filename: the filename we're gonna read
static removeDir (line 106)

Recursive function deleting a directory

  • return: true if all the content has been removed
  • author: Loic Mathaud
  • since: 1.0b1
  • access: public
static boolean removeDir (string $path, [boolean $deleteParent = true], [array $except = array()])
  • string $path: The path of the directory to remove recursively
  • boolean $deleteParent: If the path must be deleted too
  • array $except: filenames and suffix of filename, for files to NOT delete
static write (line 43)

Write a file to the disk.

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

static void write ( $file,  $data)
  • $file
  • $data

Documentation generated on Mon, 26 Oct 2015 21:53:31 +0100 by phpDocumentor 1.4.3