mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
fixing File again adding info property
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5223 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
31dd607fbe
commit
05d5972dee
2 changed files with 26 additions and 11 deletions
|
@ -56,6 +56,13 @@ class File extends Object{
|
|||
* @access public
|
||||
*/
|
||||
var $name = null;
|
||||
/**
|
||||
* file info
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $info = null;
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
@ -170,11 +177,13 @@ class File extends Object{
|
|||
* @access public
|
||||
*/
|
||||
function info() {
|
||||
$info = pathinfo($this->pwd());
|
||||
if(!isset($info['filename'])) {
|
||||
$info['filename'] = $this->filename();
|
||||
if($this->info == null) {
|
||||
$this->info = pathinfo($this->pwd());
|
||||
}
|
||||
return $info;
|
||||
if(!isset($this->info['filename'])) {
|
||||
$this->info['filename'] = $this->filename();
|
||||
}
|
||||
return $this->info;
|
||||
}
|
||||
/**
|
||||
* Returns the File extension.
|
||||
|
@ -183,9 +192,11 @@ class File extends Object{
|
|||
* @access public
|
||||
*/
|
||||
function ext() {
|
||||
$info = $this->info();
|
||||
if(isset($info['extension'])) {
|
||||
return $info['extension'];
|
||||
if($this->info == null) {
|
||||
$this->info();
|
||||
}
|
||||
if(isset($this->info['extension'])) {
|
||||
return $this->info['extension'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -196,8 +207,11 @@ class File extends Object{
|
|||
* @access public
|
||||
*/
|
||||
function filename() {
|
||||
if($ext = $this->ext()) {
|
||||
return basename($this->name, '.'.$ext);
|
||||
if($this->info == null) {
|
||||
$this->info();
|
||||
}
|
||||
if(isset($this->info['extension'])) {
|
||||
return basename($this->name, '.'.$this->info['extension']);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ class FileTest extends UnitTestCase {
|
|||
function testBasic() {
|
||||
|
||||
$file = dirname(__FILE__) . DS . basename(__FILE__);
|
||||
|
||||
$this->File =& new File($file);
|
||||
|
||||
$result = $this->File->pwd();
|
||||
|
@ -87,7 +88,7 @@ class FileTest extends UnitTestCase {
|
|||
$this->assertIsA($result, 'Folder');
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
function testOperations() {
|
||||
|
||||
$new = TMP . 'test_file_new.php';
|
||||
|
@ -110,6 +111,6 @@ class FileTest extends UnitTestCase {
|
|||
$result = $this->File->delete($new);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue