Add recursive filesize support to FileObject
This commit is contained in:
@@ -2,20 +2,12 @@
|
|||||||
|
|
||||||
class MediaListing_File extends MediaListing_FileObject {
|
class MediaListing_File extends MediaListing_FileObject {
|
||||||
|
|
||||||
protected $size;
|
|
||||||
|
|
||||||
public function __construct($path) {
|
public function __construct($path) {
|
||||||
if ( ! is_file($path)) {
|
if ( ! is_file($path)) {
|
||||||
throw new MediaListing_Exception_NotAFile($path);
|
throw new MediaListing_Exception_NotAFile($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::__construct(parent::TYPE_File, $path);
|
parent::__construct(parent::TYPE_File, $path);
|
||||||
|
|
||||||
$this->size = filesize($this->path);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function size() {
|
|
||||||
return $this->size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ abstract class MediaListing_FileObject {
|
|||||||
return $this->type == self::TYPE_Directory;
|
return $this->type == self::TYPE_Directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function size() {
|
||||||
|
return MediaListing_Main::recursiveFilesize($this->path);
|
||||||
|
}
|
||||||
|
|
||||||
public function type() {
|
public function type() {
|
||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user