Clean target directory

@return void
172240
public function cleanTarget()
    {
        $filesystem = new Filesystem();

        // Get files and directories to remove
        $files = array_diff(scandir($this->target), ['.', '..']);
        $files = preg_grep('/[^.gitignore]/i', $files);

        // Remove files
        foreach ($files as $file) {
            $filesystem->remove("$this->target/$file");
        }

        // Fire event
        Event::fire('target.cleaned', [$this]);
    }
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);
        }
    }
68734
private function cleanUp()
    {
        if ($this->quiet) {
            $errors = explode(PHP_EOL, ob_get_clean());
            $shown = [];

            foreach ($errors as $error) {
                if ($error && !in_array($error, $shown)) {
                    out($error, 'error');
                    $shown[] = $error;
                }
            }
        }

        if (file_exists($this->tmpPharPath)) {
            @unlink($this->tmpPharPath);
        }
        if (file_exists($this->tmpPubkeyPath)) {
            @unlink($this->tmpPharPath);
        }
    }
844456
public function purge() {
        // Get all files from the cache folder
        $contents = glob($this->_storage_path . '*');

        // Remove cache files
        foreach ($contents as $content) {
            if (is_file($content)) {
                unlink($content);
            }
        }
    }
380964
public function clean() {
    $this->logger->info('%name started.', ['%name' => get_class($this)]);

    $dataToRemove = $this->wrapper->getDataToRemove();
    foreach ($dataToRemove as $locationId => $locationData) {
      foreach ($locationData as $classId) {
        $this->mappingRepo->removeByLocationIdAndClassId($locationId, $classId);
      }
    }

    $this->logger->info('%name finished.', ['%name' => get_class($this)]);
  }
415867
protected function cleanup(): void
    {
        $this->output->writeln('');
        $this->output->write('Cleaning up... ');
        $this->output->writeln('');
        $this->output->writeln('');

        $projectDir = $this->getContainer()->getParameter('kernel.project_dir');

        try {
            $fileSystem = $this->getContainer()->get('filesystem');

            if (
                $fileSystem->exists($projectDir . '/.git') &&
                $this->questionHelper->ask(
                    $this->input,
                    $this->output,
                    $this->getConfirmationQuestion(
                        'Do you want to delete the <comment>.git</comment> folder?',
                        true
                    )
                )
            ) {
                $fileSystem->remove($projectDir . '/.git');
            }
        } catch (Exception $e) {
            // Do nothing
        }
    }
786055
private function cleanup()
	{
		foreach ($this->installationMap as $path => $packages) {
			if ($path == '__CHECKSUMS__') {
				continue;
			}

			if (count($packages)) {
				sort($this->installationMap[$path]);
				continue;
			}

			$installation_path = ltrim($path, '/\\' . DIRECTORY_SEPARATOR);
			$installation_path = getcwd() . DIRECTORY_SEPARATOR . $installation_path;

			if (is_dir($installation_path)) {

				//
				// Here's what to do with a directory
				//

				$children = array_merge(
					glob($installation_path . DIRECTORY_SEPARATOR . '/*'),
					glob($installation_path . DIRECTORY_SEPARATOR . '/.*')
				);

				//
				// Children should be at least two (one entry for current dir and another)
				// for parent dir.  Our install map is sorted by the length of the path
				// so we should only be trying to remove directories which have already had
				// other opus related/created children removed.
				//

				if (count($children) > 2) {
					continue;
				}

				if (!@rmdir($installation_path)) {
					switch ($this->integrity) {
						case 'low':
							break;

						case 'medium':
							$this->io->write(sprintf(
								self::TAB . 'Warning: unable to remove empty directory %s',
								$path
							));
							break;

						case 'high':
							throw new \Exception(sprintf(
								'Error removing empty directory %s',
								$path
							));
					}
				}

			} else {

				//
				// Here's what to do with a file
				//

				if (!@unlink($installation_path)) {
					switch ($this->integrity) {
						case 'low':
							break;

						case 'medium':
							$this->io->write(sprintf(
								self::TAB . 'Warning: unable to remove unused file %s; remove manually',
								$path
							));
							break;

						case 'high':
							throw new \Exception(sprintf(
								'Error removing unused file %s, restore file or check permissions and try again',
								$path
							));
					}
				}
			}

			unset($this->installationMap[$path]);
			unset($this->installationMap['__CHECKSUMS__'][$path]);
		}

		//
		// Sort our paths by length
		//

		uksort($this->installationMap, function($a, $b) {
			if (strlen($a) == strlen($b)) {
				return 0;
			}

			if (strlen($a) > strlen($b)) {
				return -1;
			}

			return 1;
		});
	}
360618
def cleanup():
        """"""
        for install_dir in linters.INSTALL_DIRS:
            try:
                shutil.rmtree(install_dir, ignore_errors=True)
            except Exception:
                print(
                    "{0}\nFailed to delete {1}".format(
                        traceback.format_exc(), install_dir
                    )
                )
                sys.stdout.flush()
437069
public function clearAll()
    {
        $path  = $this->getFilePath();
        $files = glob($path . '*' . $this->fileExtension);

        foreach ($files as $file)
        {
            @unlink($file);
        }

        static::$keys = [];
    }
525574
public function cleanup()
    {
        Cache::clear(false, 'default');
        Cache::clear(false, '_cake_model_');
        Cache::clear(false, '_cake_core_');
        $this->dispatchShell('orm_cache clear');
        $this->dispatchShell('orm_cache build');
    }
1202927
protected function cleanupChunks(){
        foreach (scandir($this->chunksFolder) as $item){
            if ($item == "." || $item == "..")
                continue;

            $path = $this->chunksFolder.DIRECTORY_SEPARATOR.$item;

            if (!is_dir($path))
                continue;

            if (time() - filemtime($path) > $this->chunksExpireIn){
                $this->removeDir($path);
            }
        }
    }
1221333
def clean_all(self, args):
        """"""
        self.clean_dists(args)
        self.clean_builds(args)
        self.clean_download_cache(args)
15167
protected function cleanup()
    {
        if (is_dir($this->dir)) {
            // Recursively delete all files and folders.
            $files = new \RecursiveIteratorIterator(
                new \RecursiveDirectoryIterator($this->dir, \RecursiveDirectoryIterator::SKIP_DOTS),
                \RecursiveIteratorIterator::CHILD_FIRST
            );

            foreach ($files as $fileinfo) {
                if ($fileinfo->isDir()) {
                    rmdir($fileinfo->getRealPath());
                } else {
                    unlink($fileinfo->getRealPath());
                }
            }
            rmdir($this->dir);
            unset($this->git);
        }
    }
747576
public function cleanup(): void
    {
        foreach ($this->getStore() as $key => $value)
        {
            $this->remove($key);
        }
    }
530381
protected function cleanRuntime()
    {
        $runtime = \Yii::getAlias('@runtime/yii2-phar');
        if (file_exists($runtime) === true) {
            FileHelper::removeDirectory($runtime);
        }
        mkdir($runtime, 0777, true);
    }
1288940
def cleanDir(self):
        '''  '''
        if os.path.isdir(self.outdir):
            baddies = ['tout.json','nout.json','hout.json']
            for file in baddies:
                filepath = os.path.join(self.outdir,file)
                if os.path.isfile(filepath):
                    os.remove(filepath)
102921
public function clean()
    {
        // Make sure the handle is close
        $this->close();

        $dir = dirname($this->getFile());
        if (is_dir($dir)) {
            $files = scandir($dir);
            foreach ($files as $file) {
                if ('.' != $file && '..' != $file) {
                    $file = $dir . DIRECTORY_SEPARATOR .  $file;
                    if (is_file($file)) {
                        unlink($file);
                    }
                }
            }
        }
        return $this;
    }