FileHandler static

This commit is contained in:
conory 2015-12-22 19:12:17 +09:00
parent 3f1fe22f3f
commit e0b8ee720f
2 changed files with 29 additions and 29 deletions

View file

@ -924,7 +924,7 @@ class Context
* @param string $path Path of the language file
* @return void
*/
public static function loadLang($path)
public static function loadLang($path)
{
global $lang;

View file

@ -15,7 +15,7 @@ class FileHandler
* @param string $source path to change into absolute path
* @return string Absolute path
*/
function getRealPath($source)
public static function getRealPath($source)
{
if(strlen($source) >= 2 && substr_compare($source, './', 0, 2) === 0)
{
@ -36,7 +36,7 @@ class FileHandler
* @param string $type If set as 'force'. Even if the file exists in target, the file is copied.
* @return void
*/
function copyDir($source_dir, $target_dir, $filter = null, $type = null)
public static function copyDir($source_dir, $target_dir, $filter = null, $type = null)
{
$source_dir = self::getRealPath($source_dir);
$target_dir = self::getRealPath($target_dir);
@ -101,7 +101,7 @@ class FileHandler
* @param string $force Y: overwrite
* @return void
*/
function copyFile($source, $target, $force = 'Y')
public static function copyFile($source, $target, $force = 'Y')
{
setlocale(LC_CTYPE, 'en_US.UTF8', 'ko_KR.UTF8');
$source = self::getRealPath($source);
@ -124,7 +124,7 @@ class FileHandler
* @param string $filename Path of target file
* @return string The content of the file. If target file does not exist, this function returns nothing.
*/
function readFile($filename)
public static function readFile($filename)
{
if(($filename = self::exists($filename)) === FALSE || filesize($filename) < 1)
{
@ -142,7 +142,7 @@ class FileHandler
* @param string $mode a(append) / w(write)
* @return void
*/
function writeFile($filename, $buff, $mode = "w")
public static function writeFile($filename, $buff, $mode = "w")
{
$filename = self::getRealPath($filename);
$pathinfo = pathinfo($filename);
@ -164,7 +164,7 @@ class FileHandler
* @param string $filename path of target file
* @return bool Returns TRUE on success or FALSE on failure.
*/
function removeFile($filename)
public static function removeFile($filename)
{
return (($filename = self::exists($filename)) !== FALSE) && @unlink($filename);
}
@ -178,7 +178,7 @@ class FileHandler
* @param string $target Path of target file
* @return bool Returns TRUE on success or FALSE on failure.
*/
function rename($source, $target)
public static function rename($source, $target)
{
return @rename(self::getRealPath($source), self::getRealPath($target));
}
@ -190,7 +190,7 @@ class FileHandler
* @param string $target Path of target file
* @return bool Returns TRUE on success or FALSE on failure.
*/
function moveFile($source, $target)
public static function moveFile($source, $target)
{
if(($source = self::exists($source)) !== FALSE)
{
@ -209,7 +209,7 @@ class FileHandler
* @param string $target_dir Path of target directory
* @return void
*/
function moveDir($source_dir, $target_dir)
public static function moveDir($source_dir, $target_dir)
{
self::rename($source_dir, $target_dir);
}
@ -225,7 +225,7 @@ class FileHandler
* @param bool $concat_prefix If TRUE, return file name as absolute path
* @return string[] Array of the filenames in the path
*/
function readDir($path, $filter = '', $to_lower = FALSE, $concat_prefix = FALSE)
public static function readDir($path, $filter = '', $to_lower = FALSE, $concat_prefix = FALSE)
{
$path = self::getRealPath($path);
$output = array();
@ -277,7 +277,7 @@ class FileHandler
* @param string $path_string Path of target directory
* @return bool TRUE if success. It might return nothing when ftp is used and connection to the ftp address failed.
*/
function makeDir($path_string)
public static function makeDir($path_string)
{
if(self::exists($path_string) !== FALSE)
{
@ -358,7 +358,7 @@ class FileHandler
* @param string $path Path of the target directory
* @return void
*/
function removeDir($path)
public static function removeDir($path)
{
if(($path = self::isDir($path)) === FALSE)
{
@ -399,7 +399,7 @@ class FileHandler
* @param string $path Path of the target directory
* @return void
*/
function removeBlankDir($path)
public static function removeBlankDir($path)
{
if(($path = self::isDir($path)) === FALSE)
{
@ -433,7 +433,7 @@ class FileHandler
* @param string $path Path of the target directory
* @return void
*/
function removeFilesInDir($path)
public static function removeFilesInDir($path)
{
if(($path = self::getRealPath($path)) === FALSE)
{
@ -475,7 +475,7 @@ class FileHandler
* @param int $size Number of the size
* @return string File size string
*/
function filesize($size)
public static function filesize($size)
{
if(!$size)
{
@ -515,7 +515,7 @@ class FileHandler
* @param string $post_data Request arguments array for POST method
* @return string If success, the content of the target file. Otherwise: none
*/
function getRemoteResource($url, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array(), $request_config = array())
public static function getRemoteResource($url, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array(), $request_config = array())
{
try
{
@ -621,7 +621,7 @@ class FileHandler
* @param string[] $headers Headers key value array.
* @return bool TRUE: success, FALSE: failed
*/
function getRemoteFile($url, $target_filename, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array(), $request_config = array())
public static function getRemoteFile($url, $target_filename, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array(), $request_config = array())
{
if(!($body = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers,$cookies,$post_data,$request_config)))
{
@ -639,7 +639,7 @@ class FileHandler
* @param $val Size in string (ex., 10, 10K, 10M, 10G )
* @return int converted size
*/
function returnBytes($val)
public static function returnBytes($val)
{
$unit = strtoupper(substr($val, -1));
$val = (float)$val;
@ -660,7 +660,7 @@ class FileHandler
* @param array $imageInfo Image info retrieved by getimagesize function
* @return bool TRUE: it's ok, FALSE: otherwise
*/
function checkMemoryLoadImage(&$imageInfo)
public static function checkMemoryLoadImage(&$imageInfo)
{
$K64 = 65536;
$TWEAKFACTOR = 2.0;
@ -689,7 +689,7 @@ class FileHandler
* @param string $thumbnail_type Thumbnail type(crop, ratio)
* @return bool TRUE: success, FALSE: failed
*/
function createImageFile($source_file, $target_file, $resize_width = 0, $resize_height = 0, $target_type = '', $thumbnail_type = 'crop')
public static function createImageFile($source_file, $target_file, $resize_width = 0, $resize_height = 0, $target_type = '', $thumbnail_type = 'crop')
{
// check params
if (($source_file = self::exists($source_file)) === FALSE)
@ -892,7 +892,7 @@ class FileHandler
* @param string $filename Path of the ini file
* @return array ini array (if the target file does not exist, it returns FALSE)
*/
function readIniFile($filename)
public static function readIniFile($filename)
{
if(($filename = self::exists($filename)) === FALSE)
{
@ -923,7 +923,7 @@ class FileHandler
* @param array $arr Array
* @return bool if array contains nothing it returns FALSE, otherwise TRUE
*/
function writeIniFile($filename, $arr)
public static function writeIniFile($filename, $arr)
{
if(!is_array($arr) || count($arr) == 0)
{
@ -939,7 +939,7 @@ class FileHandler
* @param array $arr Array
* @return string
*/
function _makeIniBuff($arr)
public static function _makeIniBuff($arr)
{
$return = array();
foreach($arr as $key => $val)
@ -976,7 +976,7 @@ class FileHandler
* @param string $mode File mode for fopen
* @return FileObject File object
*/
function openFile($filename, $mode)
public static function openFile($filename, $mode)
{
$pathinfo = pathinfo($filename);
self::makeDir($pathinfo['dirname']);
@ -991,7 +991,7 @@ class FileHandler
* @param string $filename Target file name
* @return bool Returns TRUE if the file exists and contains something.
*/
function hasContent($filename)
public static function hasContent($filename)
{
return (is_readable($filename) && (filesize($filename) > 0));
}
@ -1002,7 +1002,7 @@ class FileHandler
* @param string $filename Target file name
* @return bool Returns FALSE if the file does not exists, or Returns full path file(string).
*/
function exists($filename)
public static function exists($filename)
{
$filename = self::getRealPath($filename);
return file_exists($filename) ? $filename : FALSE;
@ -1014,7 +1014,7 @@ class FileHandler
* @param string $dir Target dir path
* @return bool Returns FALSE if the dir is not dir, or Returns full path of dir(string).
*/
function isDir($path)
public static function isDir($path)
{
$path = self::getRealPath($path);
return is_dir($path) ? $path : FALSE;
@ -1026,7 +1026,7 @@ class FileHandler
* @param string $path Target dir path
* @return bool
*/
function isWritableDir($path)
public static function isWritableDir($path)
{
$path = self::getRealPath($path);
if(is_dir($path)==FALSE)