file: update glob function to clean correctely in relative mode
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3736 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -438,4 +438,34 @@ class test_file extends PHPUnit_Framework_TestCase
|
||||
$res = $file->mkdir ("/testDFFileDir/tptp/titi/poo", 0777, true);
|
||||
$this->assertSame ($res, true);
|
||||
}
|
||||
|
||||
public function test_glob_1 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file->chroot ("/tmp");
|
||||
$res = $file->glob ("/testDFFileDir/*");
|
||||
$this->assertSame ($res, array ("/testDFFileDir/toto",
|
||||
"/testDFFileDir/tptp"));
|
||||
}
|
||||
|
||||
public function test_glob_2 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file->chroot ("/tmp");
|
||||
$file->chdir ("/testDFFileDir");
|
||||
$res = $file->glob ("*");
|
||||
$this->assertSame ($res, array ("toto",
|
||||
"tptp"));
|
||||
}
|
||||
|
||||
public function test_glob_3 ()
|
||||
{
|
||||
$file = new file ();
|
||||
$file->chroot ("/tmp");
|
||||
$file->chdir ("/testDFFileDir");
|
||||
$res = $file->glob ("/testDFFileDir/*");
|
||||
$this->assertSame ($res, array ("/testDFFileDir/toto",
|
||||
"/testDFFileDir/tptp"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
5
file.php
5
file.php
@@ -257,7 +257,10 @@ class file
|
||||
throw new \Exception ("Glob : can't read some files", 500);
|
||||
foreach ($files as &$file)
|
||||
{
|
||||
$file = substr ($file, strlen ($this->baseDir)+$relative);
|
||||
if ($relative == 1)
|
||||
$file = substr ($file, strlen ($this->baseDir)+strlen ($this->cwd)+1);
|
||||
else
|
||||
$file = substr ($file, strlen ($this->baseDir));
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user