Esempio n. 1
0
File: Node.php Progetto: jasny/Q
 /**
  * Changes file group.
  * Use of $flags might cause an exception based on the operation system.
  * 
  * @param int|string $group  Group id or groupname 
  * @param int        $flags  Fs::% options as binary set
  * @throws Fs_Exception or ExecException if chown fails.
  */
 public function chgrp($group, $flags = 0)
 {
     if (!$this->exists($flags)) {
         throw new Fs_Exception("Unable to change group of '{$this->_path}' to '{$group}': " . ($this instanceof Fs_Symlink && is_link($this->_path) ? "Unable to dereference symlink" : "File does not exist"));
     }
     if ($flags == 0) {
         if (!@chgrp($this->_path, $group)) {
             throw new Fs_Exception("Failed to change group of '{$this->_path}' to '{$group}'", error_get_last());
         }
     } else {
         Fs::bin('chgrp')->exec($group, $this->_path, $flags & Fs::RECURSIVE ? '-r' : null, $flags & Fs::NO_DEREFERENCE ? '--no-dereference' : null, $flags & Fs::ALWAYS_FOLLOW ? '-L' : null);
     }
     $this->clearStatCache();
 }