file: glob remove the first char if there is no chroot
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3757 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -468,4 +468,30 @@ class test_file extends PHPUnit_Framework_TestCase
|
|||||||
"/testDFFileDir/tptp"));
|
"/testDFFileDir/tptp"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_glob_4 ()
|
||||||
|
{
|
||||||
|
$file = new file ();
|
||||||
|
$res = $file->glob ("/tmp/testDFFileDir/*");
|
||||||
|
$this->assertSame ($res, array ("/tmp/testDFFileDir/toto",
|
||||||
|
"/tmp/testDFFileDir/tptp"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_glob_5 ()
|
||||||
|
{
|
||||||
|
$file = new file ();
|
||||||
|
$file->chdir ("/tmp/testDFFileDir");
|
||||||
|
$res = $file->glob ("*");
|
||||||
|
$this->assertSame ($res, array ("toto",
|
||||||
|
"tptp"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_glob_6 ()
|
||||||
|
{
|
||||||
|
$file = new file ();
|
||||||
|
$file->chdir ("/tmp/testDFFileDir");
|
||||||
|
$res = $file->glob ("/tmp/testDFFileDir/*");
|
||||||
|
$this->assertSame ($res, array ("/tmp/testDFFileDir/toto",
|
||||||
|
"/tmp/testDFFileDir/tptp"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
8
file.php
8
file.php
@@ -256,12 +256,20 @@ class file
|
|||||||
// FIXME : In the exception : how found the file which is not readable ?
|
// FIXME : In the exception : how found the file which is not readable ?
|
||||||
throw new \Exception ("Glob : can't read some files", 500);
|
throw new \Exception ("Glob : can't read some files", 500);
|
||||||
foreach ($files as &$file)
|
foreach ($files as &$file)
|
||||||
|
{
|
||||||
|
if (strlen ($this->baseDir) > 1)
|
||||||
{
|
{
|
||||||
if ($relative == 1)
|
if ($relative == 1)
|
||||||
$file = substr ($file, strlen ($this->baseDir)+strlen ($this->cwd)+1);
|
$file = substr ($file, strlen ($this->baseDir)+strlen ($this->cwd)+1);
|
||||||
else
|
else
|
||||||
$file = substr ($file, strlen ($this->baseDir));
|
$file = substr ($file, strlen ($this->baseDir));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($relative == 1)
|
||||||
|
$file = substr ($file, strlen ($this->cwd)+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user