@desc A way of cleaning up deadwood files.
It assumes filenames are in the form of 'microtimes as float'.

The only reason it is 'public' is for testing purposes.
@return Number of log files deleted
352165
public function deleteAtomicLogFilesOlderThanUnixMicroTimeFloat( $microtimeFloat )
		{

		$fileNamesArray = $this->findAllAtomicLogFileNames();

		$deletedCount = 0;

		foreach ( $fileNamesArray as $fileName ) 
			{
			if ( $this->isAtomicLogFileNameOlderThanMicroTimeFloat( $fileName, $microtimeFloat )  )
				{
				$deletedCount++;
				unlink( $this->getPathToAtomicLogDirectory() . "/" . $fileName );
				}
			}

		return $deletedCount;
		}
953170
private String getLogFiles(Logger logger) {

        String test = "";
        int count = 0;
        // select the Appender from logger
        for (Appender appender : logger.getAppenders().values()) {
            // only use file appenders
            if (CmsLogFileApp.isFileAppender(appender)) {
                String fileName = CmsLogFileApp.getFileName(appender);
                String temp = "";
                temp = fileName.substring(fileName.lastIndexOf(File.separatorChar) + 1);
                test = test + temp;
                count++;
                break;
            }
        }

        //iterate all parent loggers until a logger with appender was found
        while (!logger.equals(LogManager.getRootLogger())) {

            logger = logger.getParent();
            // if no Appender found from logger, select the Appender from parent logger
            if (count == 0) {
                for (Appender appender : logger.getAppenders().values()) {
                    // only use file appenders
                    if (CmsLogFileApp.isFileAppender(appender)) {
                        String fileName = CmsLogFileApp.getFileName(appender);
                        String temp = "";
                        temp = fileName.substring(fileName.lastIndexOf(File.separatorChar) + 1);
                        test = test + temp;
                        count++;
                        break;
                    }
                }
            }
        }

        return test;
    }
243462
public long cleanup() {
		int garbageSize = 0;
		if (isCachingEnabled()) {
			System.out.println(new LogEntry(Level.VERBOSE, "Identifying expired objects"));
			ArrayList<K> garbage = getExpiredObjects();
			garbageSize = garbage.size();
			System.out.println(new LogEntry("cache cleanup: expired objects: " + garbageSize));
			for (K key : garbage) {
				clear(key);
			}
		}
		return garbageSize;
	}
1115929
public int deleteAll() {
		int count = 0;
		for (String geoPackage : propertiesMap.keySet()) {
			if (deleteAll(geoPackage)) {
				count++;
			}
		}
		return count;
	}
717081
public Long getFileCountAvg() {
        Long fileCountAvg = 0L;
        if (items.size() != 0) {
            for (TableStat item : items) {
                if (item.getEndTime().equals(item.getStartTime())) {
                    fileCountAvg += item.getFileCount();
                } else {
                    fileCountAvg += item.getFileCount() * 1000
                                    / (item.getEndTime().getTime() - item.getStartTime().getTime());
                }
            }
            fileCountAvg = fileCountAvg / items.size();
        }
        return fileCountAvg;
    }
553190
public function actionCleanup()
    {
        $fileList = StorageImporter::getOrphanedFileList();

        if ($fileList === false) {
            return $this->outputError("Could not find the storage folder to clean up.");
        }
        
        if (count($fileList) > 0) {
            foreach ($fileList as $fileName) {
                $this->output($fileName);
            }
            $this->outputInfo(count($fileList) . " files to remove.");
        }

        if (count($fileList) !== 0) {
            $success = true;
            if ($this->confirm("Do you want to delete " . count($fileList) . " files which are not referenced in the database any more? (can not be undon, maybe create a backup first!)")) {
                foreach ($fileList as $file) {
                    if (is_file($file) && @unlink($file)) {
                        $this->outputSuccess($file . " successful deleted.");
                    } elseif (is_file($file)) {
                        $this->outputError($file . " could not be deleted!");
                        $success = false;
                    } else {
                        $this->outputError($file . " could not be found!");
                        $success = false;
                    }
                }
            }
            if ($success) {
                return $this->outputSuccess(count($fileList) . " files successful deleted.");
            }
            return $this->outputError("Cleanup could not be completed. Please look into error above.");
        }
        
        return $this->outputSuccess("No orphaned files found.");
    }
625249
@Override
    public void rollLogs() {
        summaryFile = null;

        List<IncidentImpl> incidentCopies;
        synchronized (incidents) {
            incidentCopies = new ArrayList<IncidentImpl>(incidents.values());
        }

        int overage = incidentCopies.size() - 500;
        if (overage > 0) {
            // we have more than 500 incidents: we need to remove least-recently-seen
            // incidents until we're back to 500. We do this daily to prevent unchecked growth
            // in the number of incidents we remember
            List<IncidentImpl> lastSeenIncidents = new ArrayList<IncidentImpl>(incidentCopies);

            // sort the incidents by when they were last seen, rather than when they were added
            Collections.sort(lastSeenIncidents, new Comparator<IncidentImpl>() {
                @Override
                public int compare(IncidentImpl o1, IncidentImpl o2) {
                    // static method on double does the same as Long.compareTo, and we avoid
                    // object allocation or auto-boxing, etc.
                    return Double.compare(o1.getTimeStamp(), o2.getTimeStamp());
                }
            });

            // For each item we're over 500, remove one from the front of the list (least recently seen)
            synchronized (incidents) {
                for (Iterator<IncidentImpl> i = lastSeenIncidents.iterator(); i.hasNext() && overage > 0; overage--) {
                    IncidentImpl impl = i.next();
                    i.remove();

                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "FFDC cleanup -- removing " + impl.key);
                    }
                    // remove the incident from the map, and clean it up (remove the associated files)
                    incidents.remove(impl.key);
                    impl.cleanup();
                }
            }
        }

        for (IncidentImpl incident : incidentCopies) {
            incident.roll();
        }

        logSummary(incidentCopies);
    }
798252
public void deleteDiskCacheFiles() {
        final String methodName = "deleteDiskCacheFiles()";
        final File f = new File(swapDirPath);
        final CacheOnDisk cod = this;
        traceDebug(methodName, "cacheName=" + this.cacheName);
        AccessController.doPrivileged(new PrivilegedAction() {
            public Object run() {
                // delete files
                File fl[] = f.listFiles();
                for (int i = 0; i < fl.length; i++) {
                    try {
                        fl[i].delete();
                    } catch (Throwable t) {
                        com.ibm.ws.ffdc.FFDCFilter.processException(t, "com.ibm.ws.cache.CacheOnDisk.deleteDiskCacheFiles", "908", cod);
                        traceDebug(methodName, "cacheName=" + cod.cacheName + "\nException: " + ExceptionUtility.getStackTrace(t));
                    }
                }
                return null;
            }
        });
    }
635536
public long getUsed() throws IOException{
    long used = 0;
    FileStatus[] files = listStatus(new Path("/"));
    for(FileStatus file:files){
      used += file.getLen();
    }
    return used;
  }
513204
@Override
	public long getLogFileTimestamp(File file) {
		String name = file.getName();
		// Check name for extension
		if (name == null || name.length() == 0 || !name.startsWith(TEXTLOGPREF) || !name.endsWith(TEXTLOGEXT)) {
			return -1L;
		}
		long result = -1L;
		try {
			Date date = DATEFORMAT.parse(name.substring(TEXTLOGPREF.length(), name.length() - TEXTLOGEXT.length()));
			result = date.getTime();
		} catch (ParseException ex) {
			// Fall through to return -1L;
		}
		return result;
	}
1312433
public int deleteIds() {
		int deleted = 0;
		try {
			if (contentsIdDao.isTableExists()) {
				deleted = contentsIdDao.delete(contentsIdDao.deleteBuilder()
						.prepare());
			}
		} catch (SQLException e) {
			throw new GeoPackageException(
					"Failed to delete all contents ids. GeoPackage: "
							+ geoPackage.getName(), e);
		}
		return deleted;
	}
599307
public static function removeOldFiles() {
		
		if (!is_dir(static::TEMP_FOLDER)) {
			return;
		}
		
		$app = Application::getInstance();
		$counter = 0;

		$files = Utilities::getDirectoryFilenames(static::TEMP_FOLDER);

		foreach ($files as $file) {

			$pathFile	= APPLICATION_PATH . '/' .static::TEMP_FOLDER . '/' . $file;
			$fileLife	= time() - filemtime($pathFile);
			$maxLife	= static::FILE_EXPIRE * 60;
			
			if ($fileLife > $maxLife) {
				$counter++;
				unlink($pathFile);
			}

		}
		
		if ($counter) {
			$app->logEvent($counter . ' files has been deleted from ' . static::TEMP_FOLDER);
		} else {
			$app->logEvent('No old files deleted from ' . static::TEMP_FOLDER);
		}
		
	}
1360185
public function cleanLog()
    {
        $em = $this->getEm();
        $lifetime = array(
            Mapper\Cronjob::STATUS_SUCCESS  =>
                $this->getSuccessLogLifetime() * 60,
            Mapper\Cronjob::STATUS_MISSED   =>
                $this->getFailureLogLifetime() * 60,
            Mapper\Cronjob::STATUS_ERROR    =>
                $this->getFailureLogLifetime() * 60,
        );

        $history = $em->getRepository('AdfabCore\Entity\Cronjob')
            ->getHistory();

        $now = time();
        foreach ($history as $job) {
            if ($job->getExecuteTime()
                && $job->getExecuteTime()->getTimestamp()
                    < $now - $lifetime[$job->getStatus()]) {
                $em->remove($job);
            }
        }

        $em->flush();

        return $this;
    }
691754
private void removeOldLogs()
  {
    try {
      Path path = getPath();
      Path parent = path.getParent();

      ArrayList<String> matchList = new ArrayList<String>();

      Pattern archiveRegexp = getArchiveRegexp();
      Files.list(parent).forEach(child->{
        String subPath = child.getFileName().toString();
        
        Matcher matcher = archiveRegexp.matcher(subPath);

        if (matcher.matches())
          matchList.add(subPath);
      });

      Collections.sort(matchList);

      if (_rolloverCount <= 0 || matchList.size() < _rolloverCount)
        return;

      for (int i = 0; i + _rolloverCount < matchList.size(); i++) {
        try {
          Files.delete(parent.resolve(matchList.get(i)));
        } catch (Throwable e) {
        }
      }
    } catch (Throwable e) {
    }
  }
1196220
int getNumStorageDirs(NameNodeDirType dirType) {
    if(dirType == null)
      return getNumStorageDirs();
    Iterator<StorageDirectory> it = dirIterator(dirType);
    int numDirs = 0;
    for(; it.hasNext(); it.next())
      numDirs++;
    return numDirs;
  }
117239
public static int getNumberOfColumnsInFile(String filename, String delimiter) {
    try {
      BufferedReader in = new BufferedReader(new FileReader(filename));
      String line;
      while ((line = in.readLine()) != null) {
        String[] parts = line.split(delimiter);
        in.close();
        return parts.length;
      }
      in.close();
      // File is empty.
      return 0;
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
819354
public synchronized int cleanCache(float maxAge) {

        // calculate oldest possible date for the cache files
        long expireDate = System.currentTimeMillis() - (long)(maxAge * 60.0f * 60.0f * 1000.0f);
        File basedir = new File(m_rfsRepository);
        // perform the cache cleanup
        int count = 0;
        if (basedir.canRead() && basedir.isDirectory()) {
            File[] files = basedir.listFiles();
            if (files != null) {
                for (int i = 0; i < files.length; i++) {
                    File f = files[i];
                    if (f.canWrite()) {
                        if (f.lastModified() < expireDate) {
                            try {
                                f.delete();
                                count++;
                            } catch (Exception e) {
                                if (LOG.isWarnEnabled()) {
                                    LOG.warn(
                                        Messages.get().getBundle().key(
                                            Messages.LOG_EXCERPT_CACHE_DELETE_ERROR_1,
                                            f.getAbsolutePath()),
                                        e);
                                }
                            }
                        }
                    }
                }
            }
        }
        return count;
    }