summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/helpers/file_helper.php2
-rw-r--r--tests/codeigniter/helpers/directory_helper_test.php19
2 files changed, 15 insertions, 6 deletions
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 1b8efff27..4b45a62d0 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -275,7 +275,7 @@ if ( ! function_exists('get_file_info'))
switch ($key)
{
case 'name':
- $fileinfo['name'] = substr(strrchr($file, DIRECTORY_SEPARATOR), 1);
+ $fileinfo['name'] = basename($file);
break;
case 'server_path':
$fileinfo['server_path'] = $file;
diff --git a/tests/codeigniter/helpers/directory_helper_test.php b/tests/codeigniter/helpers/directory_helper_test.php
index 41370e6e7..d86047349 100644
--- a/tests/codeigniter/helpers/directory_helper_test.php
+++ b/tests/codeigniter/helpers/directory_helper_test.php
@@ -14,6 +14,8 @@ class Directory_helper_test extends CI_TestCase {
public function test_directory_map()
{
+ $ds = DIRECTORY_SEPARATOR;
+
$structure = array(
'libraries' => array(
'benchmark.html' => '',
@@ -26,11 +28,18 @@ class Directory_helper_test extends CI_TestCase {
vfsStream::create($structure, $this->_test_dir);
+ // opendir() seems to fail on Windows + vfsStream when there are trailing slashes in directory names
+ if ( ! @opendir(vfsStream::url('testDir')))
+ {
+ $this->markTestSkipped();
+ return;
+ }
+
// test default recursive behavior
$expected = array(
- 'libraries/' => array(
+ 'libraries'.$ds => array(
'benchmark.html',
- 'database/' => array('active_record.html', 'binds.html'),
+ 'database'.$ds => array('active_record.html', 'binds.html'),
'email.html',
'0'
)
@@ -39,12 +48,12 @@ class Directory_helper_test extends CI_TestCase {
$this->assertEquals($expected, directory_map(vfsStream::url('testDir')));
// test detection of hidden files
- $expected['libraries/'][] = '.hiddenfile.txt';
+ $expected['libraries'.$ds][] = '.hiddenfile.txt';
- $this->assertEquals($expected, directory_map(vfsStream::url('testDir'), FALSE, TRUE));
+ $this->assertEquals($expected, directory_map(vfsStream::url('testDir'), 0, TRUE));
// test recursion depth behavior
- $this->assertEquals(array('libraries/'), directory_map(vfsStream::url('testDir'), 1));
+ $this->assertEquals(array('libraries'.$ds), directory_map(vfsStream::url('testDir'), 1));
}
}