var $handler;
/**
- * @param $path
- * @param $mime
+ * @param $path string Storage path
+ * @param $mime string
* @return UnregisteredLocalFile
*/
static function newFromPath( $path, $mime ) {
if ( $path ) {
$this->path = $path;
} else {
+ $this->assertRepoDefined();
$this->path = $repo->getRootDirectory() . '/' .
$repo->getHashPath( $this->name ) . $this->name;
}
function getMimeType() {
if ( !isset( $this->mime ) ) {
$magic = MimeMagic::singleton();
- $this->mime = $magic->guessMimeType( $this->getPath() );
+ $this->mime = $magic->guessMimeType( $this->getLocalRefPath() );
}
return $this->mime;
}
if ( !$this->getHandler() ) {
return false;
}
- return $this->handler->getImageSize( $this, $this->getPath() );
+ return $this->handler->getImageSize( $this, $this->getLocalRefPath() );
}
function getMetadata() {
if ( !$this->getHandler() ) {
$this->metadata = false;
} else {
- $this->metadata = $this->handler->getMetadata( $this, $this->getPath() );
+ $this->metadata = $this->handler->getMetadata( $this, $this->getLocalRefPath() );
}
}
return $this->metadata;
}
function getSize() {
- if ( file_exists( $this->path ) ) {
- return filesize( $this->path );
- } else {
- return false;
+ $this->assertRepoDefined();
+ $props = $this->repo->getFileProps( $this->path );
+ if ( isset( $props['size'] ) ) {
+ return $props['size'];
}
+ return false; // doesn't exist
}
}