removes files that created before $fileHandleTime
544099
private function removeOldFiles()
    {
        if ($handle = opendir($this->uploadDir)) {

            while (false !== ($file = readdir($handle))) {
                if (is_file($file)) {
                    if (filectime($this->uploadDir . $file) < (time() - $this->fileHandleTime)) {
                        unlink($this->uploadDir . $file);
                    }
                }
            }
        }
    }
714025
protected function _cleanFilesStack()
    {
        if (true===$this->isCleaned_files_stack) {
            return;
        }

        $new_stack = array();
        foreach ($this->files_stack as $_file) {
            if (is_object($_file) && ($_file instanceof \SplFileInfo)) {
                $new_stack[] = $_file;
            } elseif (is_string($_file) && @file_exists($_file)) {
                $new_stack[] = new \SplFileInfo($_file);
            } elseif (false===$this->silent) {
                throw new \RuntimeException(
                    sprintf('[Compressor] Source to process "%s" not found!', $_file)
                );
            }
        }
        $this->files_stack = $new_stack;
        $this->isCleaned_files_stack = true;
    }
128090
private void purgeUploadedFiles() {
        long currentTimeMillis = System.currentTimeMillis();

        // Do purge if purge delay is past before last purge
        // -------------------------------------------------
        long nextPurgeInMillis =
                this.m_lastPurgeInMillis + this.m_purgeDelayInMillis;
        if (nextPurgeInMillis < currentTimeMillis) {
            this.m_lastPurgeInMillis = currentTimeMillis;

            // Compute limit file time to purged
            // ---------------------------------
            long minStartTime =
                    currentTimeMillis - (this.m_uploadStorageMinutes * 60000);

            // List files to purge and remove filename to map
            // This operation is synchronized to be thread-safe
            // ------------------------------------------------
            final List<String> removeList = new ArrayList<String>();
            synchronized (this.m_uploadStartTime) {
                for (Entry<String, Long> entry :
                        m_uploadStartTime.entrySet()) {
                    String filename = entry.getKey();
                    long startTime = entry.getValue().longValue();
                    if (startTime < minStartTime) {
                        removeList.add(filename);
                    }
                }
                for (String filename : removeList) {
                    this.m_uploadStartTime.remove(filename);
                }
            }

            // Delete file to purged
            // This operation is out of synchronised block for performances
            // ------------------------------------------------------------
            for (int i = 0; i < removeList.size(); i++) {
                String id = removeList.get(i);

                File file = new File(this.m_tempDir, id);
                if (file.exists()) {
                    if (file.delete()) {
                        logger.info("Removed uploaded file '{}' because it expired.", id);
                    } else {
                        logger.warn("Could not remove expired uploaded file '"
                                    + id + "'. Check permissions in " + m_tempDir.getPath() + " directory.");
                    }
                }
            }
        }
    }
1105895
def _clean_file(self, filename):
        """"""
        if not os.path.exists(filename):
            return
        self.announce("removing '{}'".format(filename))
        if not self.dry_run:
            os.remove(filename)
641007
function cleanFolder(outPath) {
    try {
        var stat = fs.lstatSync(outPath);
        if (stat.isDirectory()) {
            wrench.rmdirSyncRecursive(outPath);
        } else  {
            fs.unlinkSync(outPath);
        }
    } catch (e) {
        if (e.code != "ENOENT") throw e;
    }
}
1317599
protected function deleteIgnoredFiles()
    {
        if ($this->ignore) {
            foreach ($this->phpci->ignore as $file) {
                $cmd = 'rm -Rf "%s/%s"';
                if (IS_WIN) {
                    $cmd = 'rmdir /S /Q "%s\%s"';
                }
                $this->phpci->executeCommand($cmd, $this->directory, $file);
            }
        }
    }
1237289
function cleanup($args)
    {
        // $_SESSION['compose']['attachments'] is not a complete record of
        // temporary files because loading a draft or starting a forward copies
        // the file to disk, but does not make an entry in that array
        if (is_array($_SESSION['plugins']['filesystem_attachments'])) {
            foreach ($_SESSION['plugins']['filesystem_attachments'] as $group => $files) {
                if ($args['group'] && $args['group'] != $group) {
                    continue;
                }

                foreach ((array)$files as $filename) {
                    if (file_exists($filename)) {
                        unlink($filename);
                    }
                }

                unset($_SESSION['plugins']['filesystem_attachments'][$group]);
            }
        }
        return $args;
    }
794566
public function clearCommand()
    {
        $startTimestamp = time();

        $path = FLOW_PATH_ROOT . 'Data/MagicWandStash';
        FileUtils::removeDirectoryRecursively($path);

        #################
        # Final Message #
        #################

        $endTimestamp = time();
        $duration = $endTimestamp - $startTimestamp;

        $this->renderHeadLine('Done');
        $this->renderLine('Cleanup successful in %s seconds', [$duration]);
    }
443861
protected function cleanup()
    {
        $this->filesystem->remove($this->tmpFolder);
        $this->root = null;
        $this->urlsets = array();
    }
421397
def clean_up(group, identifier, date):
    
    #log.error('exception raised, cleaning up files.')
    glob_pat = '{g}.{d}.mbox*'.format(g=group, d=date)
    for f in glob(glob_pat):
        #log.error('removing {f}'.format(f=f))
        try:
            os.remove(f)
        except OSError:
            continue
    glob_pat = '{id}_state.json'.format(id=identifier)
    for f in glob(glob_pat):
        #log.error('removing {f}'.format(f=f))
        try:
            os.remove(f)
        except OSError:
            continue
    return True
227202
protected function cleanupAction()
    {
        $days = 2;
        $date = new \DateTime();
        $date->modify("-$days day");

        $filter = array("before" => $date->format("Y-m-d"),
                        "isDraft" => 1);
        
        $applications    = $this->fetchApplications($filter);
        $documentManager = $this->documentManager;

        $count = count($applications);
        $i=0;

        echo  $count . " applications in Draft Mode and older than " . $days . " days will be deleted\n";

        $progress = new ProgressBar($count);

        foreach ($applications as $application) {
            $progress->update($i++, 'Application ' . $i . ' / ' . $count);
            try {
                $documentManager->remove($application);
            } catch (\Exception $e) {
                // log something
                $e->getCode();
            }
        }
        $progress->update($i, 'clean up database');
        $documentManager->flush();
        $progress->finish();
    }
730186
function removeFilesFromCache(updateObject) {
    var fileList = updateObject.fileList || [],
        filesInSearchScope = updateObject.filesInSearchScope || [],
        i = 0;
    for (i = 0; i < fileList.length; i++) {
        delete projectCache[fileList[i]];
    }
    function isNotInRemovedFilesList(path) {
        return (filesInSearchScope.indexOf(path) === -1) ? true : false;
    }
    files = files ? files.filter(isNotInRemovedFilesList) : files;
}
942689
protected function removePresets()
    {
        $files = new Filesystem;
        $files->delete("{$this->sageRoot}/resources/assets/styles/autoload/_tachyons.scss");
        $files->delete("{$this->sageRoot}/resources/assets/styles/autoload/_bootstrap.scss");
        $files->delete("{$this->sageRoot}/resources/assets/styles/autoload/_bulma.scss");
        $files->delete("{$this->sageRoot}/resources/assets/styles/autoload/_foundation.scss");
        $files->delete("{$this->sageRoot}/resources/assets/scripts/autoload/_bootstrap.js");
        $files->delete("{$this->sageRoot}/resources/assets/scripts/autoload/_foundation.js");
        $files->delete("{$this->sageRoot}/resources/assets/build/webpack.config.preset.js");
        $files->delete("{$this->sageRoot}/resources/assets/styles/tailwind.config.js");
    }
347237
protected function cleanupOldChunks()
    {
        if ($this->useChunks === false) {
            // We have no write access. Do nothing.
            return;
        }

        static $beenHere = false;

        // We only do this once.
        if ($beenHere === true) {
            return;
        }

        $beenHere = true;
        // Clean up leftover files.
        $chunkList = glob($this->chunkDir . '*.Krexx.tmp');
        if (empty($chunkList) === false) {
            $now = time();
            foreach ($chunkList as $file) {
                // We delete everything that is older than 15 minutes.
                if (($this->pool->fileService->filetime($file) + 900) < $now) {
                    $this->pool->fileService->deleteFile($file);
                }
            }
        }
    }
513854
function remove(path) {
	let files = [];
	if( fs.existsSync(path) ) {
		if(fs.statSync(path).isFile()){
			fs.unlinkSync(path);
			return;
		}

		files = fs.readdirSync(path);
		files.forEach(function(file, index){
			let curPath = path + "/" + file;
			if(fs.statSync(curPath).isDirectory()) {
				remove(curPath)
			} else {
				fs.unlinkSync(curPath);
			}
		});
		fs.rmdirSync(path, err=>console.error(err));
	}
}
104573
def CleanUp(self, path):
    """"""
    try:
      if os.path.exists(path):
        os.remove(path)
    except (OSError, IOError) as e:
      logging.info("Failed to remove temporary file %s. Err: %s", path, e)
310213
async function removeExpiredLogFiles(logdir, maxDays, logger) {
  // ignore not exists dir
  const exists = await fs.exists(logdir);
  if (!exists) return;

  const files = await fs.readdir(logdir);
  const expriedDate = moment().subtract(maxDays, 'days').startOf('date');
  const names = files.filter(file => {
    const name = path.extname(file).substring(1);
    if (!/^\d{4}\-\d{2}\-\d{2}/.test(name)) {
      return false;
    }
    const date = moment(name, 'YYYY-MM-DD').startOf('date');
    if (!date.isValid()) {
      return false;
    }
    return date.isBefore(expriedDate);
  });
  if (names.length === 0) {
    return;
  }

  logger.info(`[egg-logrotator] start remove ${logdir} files: ${names.join(', ')}`);

  await Promise.all(names.map(name => {
    const logfile = path.join(logdir, name);
    return fs.unlink(logfile)
      .catch(err => {
        err.message = `[egg-logrotator] remove logfile ${logfile} error, ${err.message}`;
        logger.error(err);
      });
  }));
}