Determines whether or not we need to reprocess the file.

@param string $filename
@return boolean
976851
public function shouldProcess($filename)
    {
        // Derive the name of the file to use
        $destination = $this->getFinalName($filename);

        // Does the destination file exist?
        if(!File::exists($destination))
        {
            // It doesn't exist, so we will need to process
            return true;
        }

        // Otherwise compare the date stamps
        $destinationChanged = File::lastModified($destination);
        $currentChanged = File::lastModified($filename);

        // Which one was last modified later
        if($currentChanged > $destinationChanged)
        {
            // Our destination is older than the actual file, so update
            return true;
        }

        // Touch the file so that we know it's up-to-date
        touch($destination);

        // We don't need to process the file (the old version will do)
        return false;
    }
1056336
public function equals( $fileName )
	{
		$toCompare	= FS_File_Reader::load( $fileName );
		$thisFile	= FS_File_Reader::load( $this->fileName );
		return( $thisFile == $toCompare );
	}
702948
protected function cleanFilename($filename)
    {
        /** @var FileIDHelper $helper */
        $helper = Injector::inst()->get(HashFileIDHelper::class);
        return $helper->cleanFilename($filename);
    }
138476
private function createFileDirIfNotExists(string $filename): bool
    {
        $pathinfo = pathinfo($filename);
        if (isset($pathinfo['dirname']) && $pathinfo['dirname'] !== '.') {
            if (is_dir($pathinfo['dirname'])) {
                return true;
            } elseif (is_file($pathinfo['dirname'])) {
                return false;
            } else {
                return $this->createDirIfNotExists($pathinfo['dirname']);
            }
        }
        return false;
    }
53941
public function delete($fileName)
    {
        $path = $this->getPathBase($fileName);

        if (!file_exists($path)) {
            return;
        }

        return unlink($path);
    }
1139723
final public function restore($fname = null)
	{
		if (is_null($fname)) {
			$fname = $this->database;
		}
		if ($this->pathExtension($fname) === '') {
			$fname .= '.sql';
		}
		if ($this->pathDirname($fname) === '.') {
			$fname = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $fname;
		}

		if (@file_exists($fname) and $sql = @file_get_contents($fname)) {
			return ($this->exec($sql) > 0);
		}
		return false;
	}
819860
public function purgeFile($filename)
    {
        if (isset($this->_fileHandlers[$filename])) {
            $this->_fileHandlers[$filename]->close();
        }
        unset($this->_fileHandlers[$filename]);
    }
601675
protected function checkIfFileNameIsSafe(string $fileName)
    {
        $allowedFileNames = $this->getLanguageFiles(true);

        if (!in_array($fileName, $allowedFileNames)) {
            return false;
        }

        return true;
    }
104422
protected function validateFilePath($fileName) {
		if (!file_exists($fileName)) {
			throw new IOException("File $fileName does not exists");
		}
		if (!is_file($fileName)) {
			throw new IOException("$fileName must be a file");
		}
		if (!is_readable($fileName)) {
			throw new IOException("File $fileName is not readable");
		}
		return true;
	}
1085410
public function exists($filename)
    {
        $filename = $this->path($filename);

        if (!$this->isDirectory($filename)) {
            return file_exists($filename);
        }

        $tmp = getcwd();

        $r = chdir($filename);

        chdir($tmp);

        return $r;
    }
80490
protected function _isMetadatasFile($fileName)
    {
        $id = $this->_fileNameToId($fileName);
        if (substr($id, 0, 21) == 'internal-metadatas---') {
            return true;
        } else {
            return false;
        }
    }
940203
private function shouldCopyFileInstead($file)
    {
        // Check if it should not be processed.
        if ($this->isExcludedFromVerbatim($file)) {
            return false;
        }

        foreach ($this->copyVerbatimPatterns as $pattern) {
            if (Str::is($pattern, $file)) {
                return true;
            }
        }

        return false;
    }
118673
function isWriteable( $filename = false )
    {
        if ( !$filename )
            $filename = $this->FileName;
        return $this->doIsWriteable( $filename );
    }
1224941
public function fileExists($filename)
    {
        return isset($this->_fileHandlers[$filename]) ||
               file_exists($this->_dirPath . '/' . $filename);
    }
449729
protected function isExcluded($filename)
    {
        foreach ($this->config->getExcludedFiles() as $excludedFile) {
            if ($filename === $excludedFile) {
                return true;
            }
        }
        foreach ($this->config->getExcludedDirs() as $excludedDir) {
            if (strpos($filename, $excludedDir) === 0) {
                return true;
            }
        }
        return false;
    }
1267444
protected function uncompress($fileName)
	{
		$fileNameUncompressed = $this->getUncompressedFileName($fileName);
		$command = sprintf('gzip -dc %s > %s', $fileName, $fileNameUncompressed);
		if ($this->console->run($command) !== true)
			$this->line($this->colors->getColoredString("\n".'Uncompress of gzipped file failed.'."\n",'red'));

		return $fileNameUncompressed;
	}
238189
public function isEncoded( $fileName )
	{
		if( file_exists( $fileName ) )
		{
			$fp	= fopen( $fileName, "r" );
			$code	= fgets( $fp, strlen( $this->outcodePrefix ) );
			if( $code == $this->outcodePrefix )
				return TRUE;
		}
		return FALSE;
	}