^Status|Final Draft|
^Todo|Proofread|
====== File Helper ======
A helper designed to manipulate files and filenames.
===== Methods =====
==== mime() ====
'mime' finds the MIME-type of a file first by using PHP's built-in database and then Kohana's MIME configuration file (system/config/mimes.php).
The parameters are:
* param: [string] filename to check MIME-type of
* return: [mixed] string if found, FALSE if not found
**Example:**
$file = 'my_movie.ogg'
echo $file.' ('.file::mime($file).')';
my_movie.ogg (application/ogg)
==== split() ====
'split' splits a file into pieces matching a specific size indicated in megabytes.
The parameters are:
* param: [string] file to be split
* param: [string] directory to output to, defaults to the same directory as the file
* param: [integer] size, in MB, for each chunk to be
* return: [integer] The number of pieces that were created.
**Example:**
$file = 'humpty_dumpty.mp3'; // pretend it is 7.8 MB large
echo (file_exists($file)) ? file::split($file,FALSE,2) : 'can not find file!' ;
4
Directory listing:
-rwxrwxrwx 1 www-data www-data 8186302 2008-05-06 20:11 humpty_dumpty.mp3
-rw-r--r-- 1 www-data www-data 2097152 2008-05-06 20:15 humpty_dumpty.mp3.001
-rw-r--r-- 1 www-data www-data 2097152 2008-05-06 20:15 humpty_dumpty.mp3.002
-rw-r--r-- 1 www-data www-data 2097152 2008-05-06 20:15 humpty_dumpty.mp3.003
-rw-r--r-- 1 www-data www-data 1894846 2008-05-06 20:15 humpty_dumpty.mp3.004
==== join() ====
'join' joins splited files (possibly by file::split()), assuming a .### extension.
The parameters are:
* param: [string] split filename, without .000 extension
* param: [string] output filename, if different then an the filename
* return: [integer] The number of pieces that were joined.
**Example:**
$file_in = 'humpty_dumpty.mp3'; // from our last example
$file_out = 'humpty_dumpty-back_together_again.mp3'; // output name
echo file::join($file_in,$file_out);
4
Directory listing:
-rwxrwxrwx 1 www-data www-data 8186302 2008-05-06 20:11 humpty_dumpty.mp3
-rw-r--r-- 1 www-data www-data 2097152 2008-05-06 20:15 humpty_dumpty.mp3.001
-rw-r--r-- 1 www-data www-data 2097152 2008-05-06 20:15 humpty_dumpty.mp3.002
-rw-r--r-- 1 www-data www-data 2097152 2008-05-06 20:15 humpty_dumpty.mp3.003
-rw-r--r-- 1 www-data www-data 1894846 2008-05-06 20:15 humpty_dumpty.mp3.004
-rw-r--r-- 1 www-data www-data 8186302 2008-05-06 20:17 humpty_dumpty-back_together_again.mp3