Files
media-listing/source/lib/MediaListing/FileObject.class.php
Ben Roberts 65c560cdf0 Initial commit
Working directory listing. Hardcoded sidebar template.
2011-01-16 23:00:00 +00:00

56 lines
1.2 KiB
PHP

<?php
abstract class MediaListing_FileObject {
const TYPE_File = 1;
const TYPE_Directory = 2;
protected $type;
protected $basename;
protected $path;
public static function create($path, $parent = null, $scan = true) {
if ( ! file_exists($path)) {
throw new MediaListing_Exception_FileNotFound($path);
}
switch (filetype($path)) {
case "file": {
return new MediaListing_File($path);
} break;
case "dir": {
return new MediaListing_Directory($path, $parent, $scan);
} break;
}
}
protected function __construct($type, $path) {
$this->type = $type;
$this->path = $path;
$this->basename = basename($path);
}
public function isFile() {
return $this->type == self::TYPE_File;
}
public function isDirectory() {
return $this->type == self::TYPE_Directory;
}
public function type() {
return $this->type;
}
public function path() {
return $this->path;
}
public function basename() {
return $this->basename;
}
}
?>