@return void

@todo Add option for excludes and option for includes
@todo Add option for whether to copy over permissions. Only "visibility" is possible with Flysystem since not
all filesystems have the same concept of permissions
501236
protected function configure()
    {

        $filesystemAdapterNames = $this->mountManager->getFilesystemPrefixes();
        $this->setName('filesystem:sync')
            ->addArgument(
                'source',
                InputArgument::REQUIRED,
                "Source path in the format {adapter}://{path}.\nAvailable Adapters: <comment>" . implode(
                    ', ',
                    $filesystemAdapterNames
                )
                . '</comment>'
            )
            ->addArgument(
                'destination',
                InputArgument::REQUIRED,
                "Destination path in the format {adapter}://{path}.\nAvailable Adapters: <comment>" . implode(
                    ', ',
                    $filesystemAdapterNames
                )
                . '</comment>'
            )
            ->addOption(
                'delete',
                null,
                InputOption::VALUE_NONE,
                'Delete files in destination filesystem that do not exist in source'
            )
            ->addOption(
                'ignore-timestamps',
                null,
                InputOption::VALUE_NONE,
                'Push all files, even if a newer matching file exists on the destination'
            )
            ->addOption(
                'exclude',
                null,
                InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
                'Path to exclude, in rsync format'
            )
            ->addOption(
                'include',
                null,
                InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
                'Excluded path to include, in rsync format'
            )
            ->addOption(
                'batch-size',
                null,
                InputOption::VALUE_REQUIRED,
                'Batch size for copy and delete operations',
                100
            )
            ->setDescription(
                'Copy a directory from a source filesystem directory to a destination filesystem directory.'
            )
            ->setHelp(
                "This command copies a directory from a source filesystem directory to a destination filesystem directory."
            );
    }
445835
public function clean()
    {
        try {
            $this->filesystem->deleteDir($this->localPath);
        } catch (\ErrorException $e) {
            // For reasons beyond our control, the actual owner of the directory
            // contents may not be the same as the current user. Therefore we need
            // to catch ErrorException and throw an expected exception with informing
            // the current user.
            throw new FileSystemException($e->getMessage(), $e->getCode(), $e);
        }
    }
159280
protected function setAuthorizes()
    {
        $filesystem = new Filesystem;

        $files = $filesystem->glob(app_path('Admin/Controllers/*.php'));

        $authorizes = [];

        foreach ($files as $key => $value) {
            $str = Str::snake(Str::replaceLast('Controller.php', '', basename($value)));

            if (!in_array($str, $this->ignores) && !in_array($str, $this->administrators)) {
                $authorizes[] = [
                    'title' => trans('admin::' . $str . '.heading.catalog'),
                    'value' => $str,
                ];
            }

        }
        $this->authorizes = $authorizes;
    }
439326
public function run()
	{
		$this->say("Updating / adding copyright headers");
		$text    = $this->replaceInText(trim($this->getJConfig()->header->text));
		$exclude = explode(",", trim($this->getJConfig()->header->exclude));

		$path      = realpath($this->getJConfig()->source);
		$fileTypes = explode(",", trim($this->getJConfig()->header->files));

		foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)) as $filename)
		{
			if (substr($filename, 0, 1) == '.')
			{
				continue;
			}

			$file = new \SplFileInfo($filename);


			if (!in_array($file->getExtension(), $fileTypes))
			{
				continue;
			}

			// Skip directories in exclude list
			if (isset($exclude) && count($exclude))
			{
				$relative = str_replace(realpath($path), "", $file->getPath());

				// It is possible to have multiple exclude directories
				foreach ($exclude as $e)
				{
					if (stripos($relative, $e) !== false)
					{
						$this->say("Excluding " . $filename);
						continue 2;
					}
				}
			}

			// Remove previous / any doctype headers at the beginning of the file
			// Todo: needs check for class headers (as long as namespace / use / defined _jexec is there, this is no issue)
			$this->removeHeader($file);
			$this->addHeader($file, $text);
		}

		$this->say("Finished updating copyright headers");
	}
460133
public static function permissions(): array
    {
        $aPermissions = parent::permissions();

        $aPermissions['object:browse']  = 'Can browse existing objects';
        $aPermissions['object:create']  = 'Can create new objects';
        $aPermissions['object:delete']  = 'Can delete existing objects';
        $aPermissions['object:restore'] = 'Can restore deleted objects';
        $aPermissions['object:purge']   = 'Can purge deleted objects';
        $aPermissions['bucket:create']  = 'Can create new buckets';

        return $aPermissions;
    }
172411
public function canAccess()
    {
        if (!$this->app->make('config')->get('concrete.updates.enable_permissions_protection')) {
            return true; // we have turned this off temporarily which means anyone even non-logged-in users can run update.
        }

        $p = new Checker();

        return $p->canUpgrade();
    }
351764
protected function set_include_files() {
        // We normally include files.
        $includefiles = true;

        // In an import, we don't need to include files.
        if ($this->get_mode() === backup::MODE_IMPORT) {
            $includefiles = false;
        }

        // When a backup is intended for the same site, we don't need to include the files.
        // Note, this setting is only used for duplication of an entire course.
        if ($this->get_mode() === backup::MODE_SAMESITE) {
            $includefiles = false;
        }

        $this->includefiles = (int) $includefiles;
        $this->log("setting file inclusion to {$this->includefiles}", backup::LOG_DEBUG);
        return $this->includefiles;
    }
431798
private function checkPermissions()
    {
        foreach ($this->writableDirectories as $path) {
            if (!$this->filesystem->isWritable(base_path($path))) {
                $this->console->error($path . ' is not writable');
                $this->errors = true;
            }
        }
    }
1315214
private function moveFiles()
    {
        // Ensure we have the file permissions not in cache as new files were installed.
        clearstatcache();
        // Now move all the files over.
        $destinationDir = $this->file->get(self::SETTING_DESTINATION_DIR);
        $ioHandler      = $this->getIO();
        $logging        = $ioHandler->isVeryVerbose();
        $this->folders  = [];
        foreach (Finder::create()->in($this->tempDir)->ignoreDotFiles(false)->ignoreVCS(false) as $file) {
            $this->moveFile($file, $destinationDir, $logging, $ioHandler);
        }

        foreach (array_reverse($this->folders) as $folder) {
            if ($logging) {
                $ioHandler->write(sprintf('remove directory %s', $folder));
            }
            rmdir($folder);
        }
    }
1326796
protected function setAccessFileManager()
    {
        $path_from_query = $this->getQuery('cmd', 'list');
        $this->data_command = $this->command->get($path_from_query);

        if (empty($this->data_command['command_id'])) {
            return $this->data_access = false;
        }

        if (!$this->access("module_file_manager_{$this->data_command['command_id']}")) {
            return $this->data_access = false;
        }

        if (!empty($this->data_selected) && $this->isQuery('selected')) {
            return $this->data_access = true;
        }

        if (!$this->command->isAllowed($this->data_command, $this->data_file)) {
            return $this->data_access = false;
        }

        if ($this->accessPathAccessFileManager($this->data_path)) {
            return $this->data_access = true;
        }

        return $this->data_access = $this->access('module_file_manager');
    }
34501
public function revokePerms() {
        $conn = ConnectionManager::get('default');
        $stmt = $conn->execute('TRUNCATE TABLE aros_acos');
        $info = $stmt->errorInfo();
        
        if ($info != null && !empty($info)) {
            $this->Flash->success(__("All permissions dropped!"));
        } else {
            $this->Flash->error(__("Error while trying to drop permissions"));
        }
        
        /**
         * Get  Model
         */
        $models = Configure::read('AclManager.aros');
        $mCounter = 0;
        foreach ($models as $model) {
            if($mCounter == (count($models)-1)) {
                $f = $this->{$model}->find('all',
                    ['order' => [$model.'.id' => 'ASC']
                ])->first();

                $this->log($f, LOG_DEBUG);

                $this->Acl->allow([$model => ['id' => $f->id]], 'controllers');
                $this->Flash->success(__("Granted permissions to {0} with id {1}", $model, (int)$f->id));
            }
            $mCounter++;
        }
        
        $this->redirect(array("action" => "permissions"));
    }
1024514
public function grantPermissions($permissions): void
    {
        if (!is_array($permissions) && !$permissions instanceof Collection) {
            $permissions = func_get_args();
        }

        foreach ($permissions as $permission) {
            $permission = $this->resolvePermission($permission);

            $permission->assignTo($this);
        }
    }
625453
public static function configureAsRoot(): void
    {
        $filesystem = new Filesystem();
        $vendor_dir = Path::VENDOR_DIR . '/hostnet/phpcs-tool/src';
        if ($filesystem->exists($vendor_dir)) {
            return;
        }

        self::configure();

        $filesystem->mkdir($vendor_dir . '/Hostnet');
        $filesystem->symlink(__DIR__ . '/../../Sniffs', $vendor_dir . '/Hostnet/Sniffs');
        $filesystem->copy(__DIR__ . '/../../ruleset.xml', $vendor_dir . '/Hostnet/ruleset.xml');

        $filesystem->mkdir($vendor_dir . '/HostnetPaths');
        $filesystem->copy(__DIR__ . '/../../../HostnetPaths/ruleset.xml', $vendor_dir . '/HostnetPaths/ruleset.xml');
    }
1272810
def fix_permissions (self):
        """"""
        if os.name == 'posix' and not self.dry_run:
            # Make the data files we just installed world-readable,
            # and the directories world-executable as well.
            for path in self.get_outputs():
                mode = os.stat(path)[stat.ST_MODE]
                if stat.S_ISDIR(mode):
                    mode |= 0o11
                mode |= 0o44
                os.chmod(path, mode)
1159621
public static function flush()
    {
        // Ensure that this instance is constructed on flush, thus forcing
        // bootstrapping of necessary .htaccess / web.config files
        $instance = singleton(AssetStore::class);
        if ($instance instanceof FlysystemAssetStore) {
            $public = $instance->getPublicFilesystem();
            if ($public instanceof Filesystem) {
                $publicAdapter = $public->getAdapter();
                if ($publicAdapter instanceof AssetAdapter) {
                    $publicAdapter->flush();
                }
            }
            $protected = $instance->getProtectedFilesystem();
            if ($protected instanceof Filesystem) {
                $protectedAdapter = $protected->getAdapter();
                if ($protectedAdapter instanceof AssetAdapter) {
                    $protectedAdapter->flush();
                }
            }
        }
    }
1163958
def remove_excludes
      return self if config[:excludes].nil?
      config[:excludes].map { |e| Dir["#{directory}/#{e}"] }.flatten.each do |e|
        FileUtils.remove_entry_secure e
      end
      self
    end
359310
protected function setWritableDirs()
    {
        $dirs = array_unique(array_filter(array_merge(Configure::read('WRITABLE_DIRS', []), [
            getConfig('Assets.target'),
            getConfigOrFail('DatabaseBackup.target'),
            getConfigOrFail('Thumber.target'),
            BANNERS,
            LOGIN_RECORDS,
            PHOTOS,
            USER_PICTURES,
        ])));

        return Configure::write('WRITABLE_DIRS', $dirs) ? $dirs : false;
    }