Set file permissions

@param int $permissions (ex: 0644)
@param string $remote_file

@return false
353323
public function chmod($permissions = 0, $remote_file = null)
    {
        if (\ftp_chmod($this->_stream, $permissions, $remote_file)) {
            return true;
        }

        $this->error = 'Failed to set file permissions for "'.$remote_file.'"';

        return false;
    }
670187
public function setAccessMode($permissions)
    {
        switch ($permissions) {
            case File::FILE_MODE_RW_POINTER_AT_END:
            case File::FILE_MODE_W_POINTER_AT_END:
            case File::FILE_MODE_R_POINTER_AT_BEGINNING:
            case File::FILE_MODE_RW_POINTER_AT_BEGINNING:
            case File::FILE_MODE_RW_TRUNCATE_FILE_TO_ZERO_LENGTH:
            case File::FILE_MODE_W_TRUNCATE_FILE_TO_ZERO_LENGTH:
                $this->mode = $permissions;

        }

    }
1350345
public static function full_permissions($file, $perms = null)
    {
        if (is_null($perms)) {
            if (!file_exists($file)) {
                return false;
            }
            $perms = fileperms($file);
        }

        if (($perms & 0xC000) == 0xC000) {
            // Socket
            $info = 's';
        } elseif (($perms & 0xA000) == 0xA000) {
            // Symbolic Link
            $info = 'l';
        } elseif (($perms & 0x8000) == 0x8000) {
            // Regular
            $info = '-';
        } elseif (($perms & 0x6000) == 0x6000) {
            // Block special
            $info = 'b';
        } elseif (($perms & 0x4000) == 0x4000) {
            // Directory
            $info = 'd';
        } elseif (($perms & 0x2000) == 0x2000) {
            // Character special
            $info = 'c';
        } elseif (($perms & 0x1000) == 0x1000) {
            // FIFO pipe
            $info = 'p';
        } else {
            // Unknown
            $info = 'u';
        }

        // Owner
        $info .= (($perms & 0x0100) ? 'r' : '-');
        $info .= (($perms & 0x0080) ? 'w' : '-');
        $info .= (($perms & 0x0040) ?
                    (($perms & 0x0800) ? 's' : 'x') :
                    (($perms & 0x0800) ? 'S' : '-'));

        // Group
        $info .= (($perms & 0x0020) ? 'r' : '-');
        $info .= (($perms & 0x0010) ? 'w' : '-');
        $info .= (($perms & 0x0008) ?
                    (($perms & 0x0400) ? 's' : 'x') :
                    (($perms & 0x0400) ? 'S' : '-'));

        // World
        $info .= (($perms & 0x0004) ? 'r' : '-');
        $info .= (($perms & 0x0002) ? 'w' : '-');
        $info .= (($perms & 0x0001) ?
                    (($perms & 0x0200) ? 't' : 'x') :
                    (($perms & 0x0200) ? 'T' : '-'));

        return $info;
    }
33587
public static function assertFileHasPermissions($permissions, $filename, string $message = '')
    {
        if (!is_string($permissions) && !(is_int($permissions) && $permissions >= 0)) {
            throw AssertHelper::createArgumentException(__TRAIT__, 'assertFileHasPermissions', 'int (>= 0) or string', $permissions);
        }

        try {
            $constraint = new FilePermissionsIsIdenticalConstraint($permissions);
        } catch (\InvalidArgumentException $e) {
            throw AssertHelper::createArgumentExceptionWithMessage(
                __TRAIT__,
                'assertFileHasPermissions',
                $permissions,
                $e->getMessage()
            );
        }

        self::assertThatConstraint($filename, $message, 'assertFileHasPermissions', $constraint);
    }
362236
public function mkdir($path, $permissions = null)
	{
		if ( ! $this->_is_conn())
		{
			return false;
		}

		$result = ftp_mkdir($this->_conn_id, $path);

		if ($result === false)
		{
			if ($this->_debug == true)
			{
				throw new \FtpFileAccessException('Unable to create directory');
			}
			return false;
		}

		// Set file permissions if needed
		if ($permissions !== null)
		{
			$this->chmod($path, (int) $permissions);
		}

		return true;
	}
666208
public function setPermissionsAttribute($permissions)
    {
        $module = lcfirst($this->attributes['name']);

        $roles = array();

        //prefix the permission with the module name ex: user.create
        foreach ($permissions as $key => $value)
        {
            $roles[] = $module . '.' . $value;
        }

        $this->attributes['permissions'] = ( ! empty($roles)) ? json_encode($roles) : '';
    }
1091992
public void setPermission(String src, FsPermission permission
                            ) throws IOException {
    checkOpen();
    clearFileStatusCache();
    
    try {
      namenode.setPermission(src, permission);
    } catch(RemoteException re) {
      throw re.unwrapRemoteException(AccessControlException.class,
                                     FileNotFoundException.class);
    }
  }
926638
private void setFileNotWorldReadablePermissions(File file) {
       file.setReadable(false, false);
       file.setWritable(false, false);
       file.setExecutable(false, false);
       file.setReadable(true, true);
       file.setWritable(true, true);
    }
692822
public function delete($remote_file_path) {
        //get file string massage
        $remote_file_path = self::winslashes($remote_file_path);
        $this->execute('del "' . $remote_file_path . '"', $output);
        return $output;
    }
1251705
public function putFromString($remote_file, $content)
    {
        $handle = fopen('php://temp', 'w');

        fwrite($handle, $content);
        rewind($handle);

        if ($this->ftp->fput($remote_file, $handle, FTP_BINARY)) {
            return $this;
        }

        throw new FtpException('Unable to put the file "'.$remote_file.'"');
    }
138016
public function changePermission($srcFile, $permissions)
    {
        $srcFile = '/home/'.$this->userName.'/'.$srcFile;
        $this->returnCode = 'no';

        return $this->send('v-change-fs-file-permission', $this->userName, $srcFile, $permissions);
    }
952061
public function hookUserRolePermissions(array &$permissions)
    {
        $permissions['module_file_manager'] = gplcart_text('File manager: access');

        foreach ($this->getHandlers() as $command_id => $command) {
            $permissions["module_file_manager_$command_id"] = gplcart_text('File manager: perform command @name', array(
                '@name' => $command['name']));
        }
    }
415192
protected function has_system_permission($filepath, $permissions) {
        if (in_array('r', $permissions)) {
            if (!is_readable($filepath)) {
                Log::info('Not readable path "' . $filepath . '"');
                return false;
            };
        }
        if (in_array('w', $permissions)) {
            if (!is_writable($filepath)) {
                Log::info('Not writable path "' . $filepath . '"');
                return false;
            }
        }
        return true;
    }
870263
protected function setPermissions($permissions)
    {
        foreach ($permissions as $action => $permission) {
            $this->setPermission($action, $permission);
        }
    }
630992
public function chmod($remote_file, $mode)
    {
        $mode = octdec(str_pad($mode, 4, '0', STR_PAD_LEFT));
        $mode = (int) $mode;

        if (!@ftp_chmod($this->connection, $mode, $remote_file) !== false) {
            throw new \Exception("Could not change remote file to mode: " . $mode);
        }

        return true;
    }
86699
public function giveRolePermission(int $role_id, string $permission_name, bool $inverse)
    {

        $role = $this->getRole($role_id);

        $permission = PermissionModel::firstOrNew([
            'title' => $permission_name,
        ]);

        // If the role does not already have the permission
        // add it. We will also apply the inverse rule as an
        // extra attribute on save()
        if (! $role->permissions->contains($permission->id))
            $role->permissions()->save($permission, ['not' => $inverse]);

    }
643328
public function delete($remote_file = null)
    {
        if (\ftp_delete($this->_stream, $remote_file)) {
            return true;
        }

        $this->error = 'Failed to delete file "'.$remote_file.'"';

        return false;
    }