function writeAttachment(WPAttachment $obj)
{
$dstpath = gb::$site_dir . '/' . $obj->name;
$dstpathdir = dirname($dstpath);
if (!is_dir($dstpathdir)) {
$this->mkdirs($dstpathdir, count(explode('/', trim($obj->name, '/'))));
}
try {
copy($obj->wpurl, $dstpath);
@chmod($dstpath, 0664);
return true;
} catch (RuntimeException $e) {
$this->reportError($e->getMessage());
return false;
}
}