diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-03-14 09:12:36 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-03-14 09:12:36 +0100 |
commit | 3f103aaf1e182115a517117dfe44af2702667620 (patch) | |
tree | f207ef14a845bb4d8c31371c65839ea1ecf4263a /system | |
parent | 76062078b4f71740182eda6af9bd0d800111fedc (diff) | |
parent | f2915f2787170d681a50db39a6650f48eefc8d7b (diff) |
Merge pull request #1175 from toopay/path_helper
Path helper improvement
Diffstat (limited to 'system')
-rw-r--r-- | system/helpers/path_helper.php | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php index 2eb85fefa..e4fc6f157 100644 --- a/system/helpers/path_helper.php +++ b/system/helpers/path_helper.php @@ -58,21 +58,22 @@ if ( ! function_exists('set_realpath')) } // Resolve the path - if (function_exists('realpath') AND @realpath($path) !== FALSE) + if (function_exists('realpath') && @realpath($path) !== FALSE) { - $path = realpath($path); + $realpath = realpath($path); + } + else + { + $realpath = (is_dir($path) OR is_file($path)) ? $path : FALSE; } - // Add a trailing slash - $path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; - - // Make sure the path exists - if ($check_existance == TRUE && ! is_dir($path)) + if ( ! $realpath) { - show_error('Not a valid path: '.$path); + return $check_existance ? show_error('Not a valid path: '.$path) : $path; } - return $path; + // Add a trailing slash, if this is a directory + return is_dir($realpath) ? rtrim($realpath, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : $realpath; } } |