コード例 #1
0
 /**
  * @abstract
  * @param AJXP_Node $ajxpNode
  * @param String $nameSpace
  * @param array $metaData
  * @param bool $private
  * @param int $scope
  */
 public function setMetadata($ajxpNode, $nameSpace, $metaData, $private = false, $scope = AJXP_METADATA_SCOPE_REPOSITORY)
 {
     $path = $ajxpNode->getRealFile();
     if (!file_exists($path)) {
         return;
     }
     $key = $this->getMetaKey($nameSpace, $scope, $this->getUserId($private, $ajxpNode));
     if (!xattr_supported($path)) {
         throw new Exception("Filesystem does not support Extended Attributes!");
     }
     $value = base64_encode(serialize($metaData));
     xattr_set($path, $key, $value);
 }
コード例 #2
0
ファイル: FileCache.php プロジェクト: comodojo/cache
 /**
  * Set a cache element using xattr
  *
  * @param   string  $name    Name for cache element
  * @param   mixed   $data    Data to cache
  * @param   int     $ttl     Time to live
  *
  * @return  bool
  */
 private function setXattr($name, $data, $ttl)
 {
     $cacheFile = $name . ".cache";
     $cached = file_put_contents($cacheFile, $data, LOCK_EX);
     if ($cached === false) {
         $this->raiseError("Error writing cache object (File), exiting gracefully", pathinfo($cacheFile));
         $this->setErrorState();
         return false;
     }
     $tagged = xattr_set($cacheFile, "EXPIRE", $ttl, XATTR_DONTFOLLOW);
     if ($tagged === false) {
         $this->raiseError("Error writing cache ttl (File) (XATTR), exiting gracefully", pathinfo($cacheFile));
         $this->setErrorState();
         return false;
     }
     return true;
 }
コード例 #3
0
ファイル: Node.php プロジェクト: jasny/Q
 /**
  * Set file or extended attribute.
  * 
  * @param string $att    Attribute name
  * @param mixed  $value  Attribute value
  * @param int    $flags  FS::% options and/or XATTR_% options as binary set
  */
 public function setAttribute($att, $value, $flags = 0)
 {
     if ($value === null && in_array($att, array('mode', 'perms', 'uid', 'owner', 'gid', 'group'))) {
         throw new Exception("Unable to set attribute '{$att}' to null.");
     }
     switch ($att) {
         case 'mode':
         case 'perms':
             $this->chmod($value, $flags);
             break;
         case 'uid':
         case 'owner':
             $this->chown($value, $flags);
             break;
         case 'gid':
         case 'group':
             $this->chgrp($value, $flags);
             break;
         case 'mtime':
         case 'atime':
             throw new Exception("Unable to set attribute '{$att}'; Use touch() method instead.");
         case 'ctime':
         case 'size':
         case 'type':
         case 'dev':
         case 'ino':
         case 'nlink':
         case 'rdev':
         case 'blksize':
         case 'blocks':
             throw new Exception("Unable to set attribute '{$att}'; Attribute is read-only.");
         default:
             if (!extension_loaded('xattr')) {
                 throw new Exception("Unable to set attribute '{$att}' for '{$this->_path}': Not a file attribute and extended attributes are not supported.");
             }
             if (!xattr_supported($this->_path, $flags)) {
                 throw new Fs_Exception("Unable to set attribute '{$att}' for '{$this->_path}': Extended attributes are not supported for that filesystem.");
             }
             $ret = $value === null ? @xattr_remove($this->_path, $att, $flags) : @xattr_set($this->_path, $att, $value, $flags);
             if (!$ret) {
                 $error = error_get_last();
                 throw new Fs_Exception("Failed to set extended attribute '{$att}' for '{$this->_path}': {$error['message']}");
             }
             $this->clearStatCache();
     }
 }