本文整理汇总了PHP中Folder::close方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::close方法的具体用法?PHP Folder::close怎么用?PHP Folder::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder::close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Get a file
*
* @param string filename
* @return org.webdav.WebdavObject
* @throws lang.ElementNotFoundException
* @throws org.webdav.OperationNotAllowedException
*/
public function get($filename, $token = NULL)
{
$this->c->debug('FILENAME', $filename);
$this->c->debug('TOKEN', $token);
$filename = $this->_normalizePath($filename);
// check for lock
$lockinfo = $this->getLockInfo($filename);
if ($lockinfo and $lockinfo['type'] == 'exclusive' and 'opaquelocktoken:' . $lockinfo['token'] != $token) {
throw new IllegalArgumentException($filename . ' is locked exclusive');
}
if (is_dir($this->base . $filename)) {
$this->c->debug(get_class($this), '::GET Dir', $filename);
$f = new Folder($this->base . $filename);
if (!$f->exists()) {
throw new ElementNotFoundException($filename . ' not found');
}
while ($maxdepth >= 0 && ($entry = $f->getEntry())) {
$isdir = is_dir($this->base . $filename . '/' . $entry);
$atime = date('H:i:s d.m.y', fileatime($this->base . $filename . '/' . $entry));
if ($isdir) {
$flist[0][$entry] .= sprintf('
<tr>
<td><a href="%s/">%s</a></td>
<td><DIR></td>
<td>%s</td>
<td> </td>
</tr>
', rawurlencode($entry), $entry, $atime);
} else {
$flist[1][$entry] .= sprintf('
<tr>
<td><a href="%s">%s</a></td>
<td> </td>
<td>%s</td>
<td>%s Bytes</td>
</tr>
', rawurlencode($entry), $entry, $atime, filesize($this->base . $filename . '/' . $entry));
}
}
asort($flist[0]);
$html = '<table cellpadding=3>' . (strlen($filename) > 2 ? '<tr><td><a href="../">..</a></td><td><DIR></tr>' : '') . implode('', $flist[0]);
asort($flist[1]);
$flist = $html . implode('', $flist[1]) . '</table>';
$o = new WebdavObject($f->uri, NULL, strlen($flist), 'text/html', new Date(filectime($f->uri)), new Date(filemtime($f->uri)));
$o->setData($flist);
$f->close();
return $o;
}
$this->c->debug(get_class($this), '::GET filename', $filename);
$this->c->debug(get_class($this), '::GET base', $this->base);
// Open file and read contents
// contentype
if (!file_exists($this->base . $filename)) {
throw new ElementNotFoundException($filename . ' not found');
}
$f = new File($this->base . $filename);
$contentType = '';
$this->c->debug(get_class($this), '::get ', $this->base . filename);
$eProps = $this->propStorage->getProperties($f->uri);
if (!empty($eProps['getcontenttype'])) {
$contentType = $eProps['getcontenttype'][0];
}
if (empty($contentType)) {
$contentType = MimeType::getByFilename($f->uri, 'text/plain');
}
$o = new WebdavObject($f->uri, NULL, $f->size(), $contentType, new Date($f->createdAt()), new Date($f->lastModified()));
try {
$f->open(FILE_MODE_READ);
$o->setData($f->read($f->size()));
$f->close();
} catch (FileFoundException $e) {
throw new ElementNotFoundException($filename . ' not found');
}
$this->c->debug('OBJ', $o->properties);
return $o;
}
示例2: basename
$propertyFile = $param->exists('conf') ? $param->value('conf') : 'core_fonts.ini';
$pattern = basename($search);
$base = dirname($search);
printf("===> Start for %s [allfiles %s]\n", $base, $pattern);
$prop = new Properties($propertyFile);
if (!$prop->exists()) {
try {
printf("---> Creating configfile %s\n", $propertyFile);
$prop->create();
} catch (IOException $e) {
$e->printStackTrace();
exit;
}
}
// Verzeichnis durchsuchen
$d = new Folder($base);
while ($e = $d->getEntry()) {
if (is_dir($d->uri . '/' . $e) || !preg_match('/' . $pattern . '/', $e)) {
continue;
}
printf("---> Saving fontdef for %s to %s\n", $e, $propertyFile);
writeFontDef($d->uri . '/' . $e, $prop);
}
$d->close();
// Property-File schreiben
try {
$prop->save();
} catch (IOException $e) {
$e->printStackTrace();
}
delete($prop);
示例3: getMessageCount
/**
* Gets the count of messages with speciefied attribute
* or all messages when no attribute was specified
*
* @param peer.mail.Mailfolder f
* @param int attr default 0xFFFF
* @return int count
*/
public function getMessageCount($f, $attr = 0xffff)
{
$this->openFolder($f);
$f = new Folder($f->name . DIRECTORY_SEPARATOR . 'cur');
if (!$f->exists()) {
return 0;
}
$cnt = 0;
$f->open();
while ($e = $f->getEntry()) {
if ($attr & $this->_getMailFlags($e)) {
$cnt++;
}
}
$f->close();
return $cnt;
}
示例4: readFiles
/**
* Read the selected directory's content
*
*/
public function readFiles()
{
$f = new Folder($this->dir);
// Disable Up button if we are at top
$this->buttons['up']->set_sensitive(strlen($this->dir) > 1);
// Update entry
$entry = $this->combo->entry;
$entry->set_text($f->uri);
// Update list
$this->files->freeze();
$this->files->clear();
try {
while ($entry = $f->getEntry()) {
$icon = $mask = NULL;
if ($dir = is_dir($f->uri . $entry)) {
// Set folder icon
$icon = $this->pixmaps['p:folder'];
$mask = $this->pixmaps['m:folder'];
} else {
if (!preg_match(':' . $this->filter . ':i', $entry)) {
continue;
}
$ext = '(n/a)';
if (FALSE !== ($p = strrpos($entry, '.')) && $p > 0) {
$ext = substr($entry, $p + 1);
}
// Check for "special" files
if (preg_match('#README|TODO|INSTALL|COPYRIGHT|NEWS#', $entry)) {
$idx = 'special.readme';
} else {
$idx = isset($this->pixmaps['p:ext.' . $ext]) ? 'ext.' . $ext : 'none';
}
// Set icon
$icon = $this->pixmaps['p:' . $idx];
$mask = $this->pixmaps['m:' . $idx];
}
// Get file owner's name
// !!! TBD: Generic approach, posix_getpwuid may not exist !!!
$owner = posix_getpwuid(fileowner($f->uri . $entry));
$this->files->set_pixtext($this->files->append(array($entry, $dir ? '' : $ext, $this->_size(filesize($f->uri . $entry)), date('Y-m-d H:i', filemtime($f->uri . $entry)), $owner['name'], substr(sprintf("%o", fileperms($f->uri . $entry)), 3 - $dir))), 0, $entry, 4, $icon, $mask);
}
// Copy folder's URI (will be full path)
$this->dir = $f->uri;
$f->close();
} catch (IOException $e) {
$e->printStackTrace();
}
$this->files->sort();
$this->files->thaw();
}