Check if $paths are writable. Permission denied list are defined in getLastPermissionDeniedList()

@param  array   $paths

@return boolean
343469
public function isWritableList(array $paths)
    {
        $permissionDeniedList = array();

        $result = true;
        foreach ($paths as $path) {
            $rowResult = $this->isWritable($path);
            if (!$rowResult) {
                $permissionDeniedList[] = $path;
            }
            $result &= $rowResult;
        }

        if (!empty($permissionDeniedList)) {
            $this->permissionDeniedList = $this->getPermissionUtils()->arrangePermissionList($permissionDeniedList);
        }

        return (bool) $result;
    }
1180726
public function hasPermission(array $permissions) {
    $sentry = App::make('sentry');
    $current_user = $sentry->getUser();
    if (!$current_user) {
      return false;
    }
    if ($permissions && (!$current_user->hasAnyAccess($permissions))) {
      return false;
    }

    return true;
  }
1103813
public static function isWritable(string $path): bool
    {
        // If it's a directory, test on a temp sub file
        if (is_dir($path)) {
            return static::isWritable($path . DIRECTORY_SEPARATOR . uniqid('test_writable', true) . '.tmp');
        }

        // Remember whether the file already existed
        $exists = file_exists($path);

        if (($f = @fopen($path, 'ab')) === false) {
            return false;
        }

        @fclose($f);

        // Delete the file if it didn't exist already
        if (!$exists) {
            static::removeFile($path);
        }

        return true;
    }
1028383
protected function isFilesystemWritable(/*# string */ $path)/*# : bool */
    {
        if ($this->getFilesystem()->isWritable()) {
            return true;
        } else {
            return $this->setError(
                Message::get(Message::STR_FS_NONWRITABLE, $path),
                Message::STR_FS_NONWRITABLE
            );
        }
    }
1041830
public function writableDirs(array $paths): self
    {
        foreach ($paths as $path) {
            $this->validatePathIsRelativeToProject($path, __METHOD__);
        }
        $this->writableDirs = $paths;

        return $this;
    }
144361
public function isReadable(array $array, string $path): bool
    {
        try {
            return $this->pa->isReadable($array, $path);
        } catch (\Exception $e) {
            return false;
        }
    }
732467
public static function setPermission(array $paths)
    {
        foreach ($paths as $path => $permission) {
            echo "chmod('$path', $permission)...";
            if (is_dir($path) || is_file($path)) {
                try {
                    if (chmod($path, octdec($permission))) {
                        echo "done.\n";
                    };
                } catch (\Exception $e) {
                    echo $e->getMessage() . "\n";
                }
            } else {
                echo "file not found.\n";
            }
        }
    }
10108
protected function _hasAllowedChildren(array $children): bool
    {
        foreach ($children as $child) {
            if ($this->Auth->urlAllowed($child['url'])) {
                return true;
            }
        }

        return false;
    }
868828
private function inPaths($pathInfo, array $paths)
    {
        foreach ($paths as $path) {
            if (preg_match('#'.$path.'#', $pathInfo)) {
                return true;
            }
        }

        return false;
    }
1267706
public function acfLoadClean($paths)
    {
        $paths = array_unique($paths);

        foreach ($paths as $path) {
            foreach (@glob($path . '/*.json') as $file) {
                $json = json_decode(file_get_contents($file));

                if (!is_array($json)) {
                    continue;
                }

                $content = file($file);

                if (trim($content[0]) == '[') {
                    array_shift($content);
                    array_pop($content);
                }

                file_put_contents($file, $content);
            }
        }

        return $paths;
    }
373407
public static function writable($path)
    {
        $path = Normalize::diskFullPath($path);

        if (!self::exist($path)) {
            return false;
        }

        return (is_dir($path) && is_writable($path));
    }
901767
protected function _canBeDeleted($path)
    {
        $type = $this->_plugin->isTheme ? 'theme' : 'plugin';
        if (!file_exists($path) || !is_dir($path)) {
            $this->err(__d('installer', "{0} directory was not found: {1}", ($type == 'plugin' ? __d('installer', "Plugin's") : __d('installer', "Theme's")), $path));

            return false;
        }

        $folder = new Folder($path);
        $folderContent = $folder->tree();
        $notWritable = [];

        foreach ($folderContent as $foldersOrFiles) {
            foreach ($foldersOrFiles as $element) {
                if (!is_writable($element)) {
                    $notWritable[] = $element;
                }
            }
        }

        if (!empty($notWritable)) {
            $this->err(__d('installer', "{0} files or directories cannot be removed from your server, please check write permissions of:", ($type == 'plugin' ? __d('installer', "Some plugin's") : __d('installer', "Some theme's"))));
            foreach ($notWritable as $path) {
                $this->err(__d('installer', '  - {0}', [$path]));
            }

            return false;
        }

        return true;
    }
636075
protected function unPublish($path)
    {
        if (($file = $this->getFileObject($path))) {
            $permissions = $file->getPermissions();
            try {
                foreach ($permissions as $permission) {
                    if ($permission->type === 'anyone' && $permission->role === 'reader') {
                        $this->service->permissions->delete($file->getId(), $permission->getId());
                    }
                }
                return true;
            } catch (Exception $e) {
                return false;
            }
        }

        return false;
    }
689910
public function allowFilesystem($path)
    {
        if (!$this->allowBackOffice()) return FALSE;
        $r = self::getDbConnection()->fetchColumn('SELECT COUNT(*) FROM users_groups_deny_filesystem WHERE path=? and group_id IN ('.implode(',',$this->getGroups()).')', array($path), 0);
        if ($r > 0) return FALSE;       
        return TRUE;
    }
1192199
protected function isWritable($path) {
        if (!is_dir($path)) {
            // Path does not exist, check parent
            return $this->isWritable(dirname($path));
        }

        // Dir exists, check if it's writable
        return is_writable($path);
    }
1261402
protected static function checkFileWritableJob(string $path, bool $truncate = false): bool
    {
        if (\file_exists($path) && (!\is_file($path) || !\is_writable($path))) {
            return false;
        }
        
        if ($truncate && \is_file($path)) {
            @\ftruncate(@\fopen($path, 'wb'), 0);
        }
        
        return true;
    }
721892
public static function delete($files)
    {
        $files = (array) $files;

        foreach ($files as $file) {
            $file = Path::clean($file);

            // Try making the file writable first. If it's read-only, it can't be deleted
            // on Windows, even if the parent folder is writable
            @chmod($file, 0777);

            // In case of restricted permissions we zap it one way or the other
            // as long as the owner is either the webserver or the ftp
            // TODO: Remove exception and use PHP7 throwable
            if (@!unlink($file)) {
                throw new FilesystemException(__METHOD__ . ': Failed deleting ' . basename($file));
            }
        }

        return true;
    }