summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/path_helper.php19
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;
}
}