summaryrefslogtreecommitdiffstats
path: root/system/helpers/path_helper.php
diff options
context:
space:
mode:
authorTaufan Aditya <toopay@taufanaditya.com>2012-03-12 15:03:37 +0100
committerTaufan Aditya <toopay@taufanaditya.com>2012-03-12 15:03:37 +0100
commit89338828264a6b50e0eb63c449a96f14f0f84076 (patch)
tree5e89cbdeb75f41a7f33d0b4e32997533eb4aafd3 /system/helpers/path_helper.php
parent5f98a1091c70e29c7596917604ec478aea443122 (diff)
Path helper improvement
Diffstat (limited to 'system/helpers/path_helper.php')
-rw-r--r--system/helpers/path_helper.php16
1 files changed, 5 insertions, 11 deletions
diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php
index 2eb85fefa..1b9bdae75 100644
--- a/system/helpers/path_helper.php
+++ b/system/helpers/path_helper.php
@@ -58,21 +58,15 @@ if ( ! function_exists('set_realpath'))
}
// Resolve the path
- if (function_exists('realpath') AND @realpath($path) !== FALSE)
- {
- $path = realpath($path);
- }
-
- // Add a trailing slash
- $path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
+ $realpath = realpath($path);
- // 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;
}
}