Checks whether archive can be opened with current system configuration
@param string $fileName
@return boolean
506673
public static function canOpenArchive($fileName)
    {
        self::checkRequirements();

        $type = self::detectArchiveType($fileName);
        if ($type !== false && self::canOpenType($type)) {
            return true;
        }

        return false;
    }
633797
protected function sourceFileExists($filename)
    {
        $fullFilename = $this->formDir . $filename;
        if (file_exists($fullFilename)) {
            return true;
        }

        return false;
    }
565986
public static boolean isArchiveFileName(String fileName) {
        String extension = getExtension(fileName);
        return ARCHIVE_EXTENSION_SET.contains(extension);
    }
140267
public function open($filename)
    {
        if ($this->opened) {
            $this->close();
        }
        $this->indentation = 0;
        $this->buffer->clear();
        $this->filename = $filename;
        $this->opened = true;

        return $this;
    }
601321
public static function decompress(string $releaseName): bool
    {
        try {
            $p = new \PharData(sprintf("%s/%s.tar.gz", Utilities::getBasePath(), $releaseName));
            $p->decompress();
        } catch (Exception $e) {
            printf('ERROR: Can not decompress the archive%s%s', PHP_EOL, $e);
            return false;
        }

        return true;
    }
519920
public static function isJpegFile($filename)
    {
        try {
            $image = new ImageFile($filename);
            if (strtolower($image->getMime()) !== @image_type_to_mime_type(IMAGETYPE_JPEG)) {
                return false;
            }

            return true;
        } catch (\RuntimeException $ex) {
            return false;
        }
    }
847163
private function tryRemoveWithLock(string $fileName): bool
    {
        if (strncasecmp(PHP_OS, 'WIN', 3) == 0) {
            // On Windows, unlinking a locked/opened file will not work, so we just attempt the delete straight away.
            // In the worst case, the unlink will just fail due to concurrent access and the caller needs to deal with that.
            return unlink($fileName);
        }
        $file = fopen($fileName, 'rb');
        if ($file === false) {
            return false;
        }

        $result = false;
        if (flock($file, LOCK_EX) !== false) {
            $result = unlink($fileName);
            flock($file, LOCK_UN);
        }
        fclose($file);

        return $result;
    }
116757
public function exists($filename)
    {
        $listing = $this->listDirectoryContents();

        $dirname_info = array_filter($listing, function ($item) use ($filename) {
            return $item['name'] === $filename;
        });

        return count($dirname_info) !== 0;
    }
720691
public function isImageFileExtensionKosher($filename) {

        // must have acceptable file extension
        $imageFileExtension = $this->ImagesHelper->filenameWithExtensionOnly($filename);

        $haystack = Config::get('lasallecmsfrontend.acceptable_image_extensions_for_uploading');

        if (in_array(strtolower($imageFileExtension), $haystack)) {
            return true;
        }

        return false;
    }
513343
private function open($archive, $create = false)
		{
			if (true === $this->_enabled) {
				$archive = repl('/', DS, $archive);

				if ($create) {
					$this->_archive	= $this->_zip->open($archive, \ZipArchive::CREATE);
				} else if (File::exists($archive)) {
					$this->_archive	= $this->_zip->open($archive);
				}

				if ($this->_archive === true) {
					$this->contents();

					return true;
				} else {
					$this->error();

					return false;
				}
			}

			return false;
		}
1289788
public function fileExists($fileName, $storageName = '')
    {
        //check whether file is set or not
        if ($fileName == '') {
            AsposeApp::getLogger()->error(Exception::MSG_NO_FILENAME);
            throw new Exception(Exception::MSG_NO_FILENAME);
        }

        //build URI
        $strURI = $this->strURIExist . $fileName;
        if ($storageName != '') {
            $strURI .= '?storage=' . $storageName;
        }
        //sign URI
        $signedURI = Utils::sign($strURI);

        $responseStream = json_decode(Utils::processCommand($signedURI, 'GET', '', ''));
        if (!$responseStream->FileExist->IsExist) {
            return FALSE;
        }
        return TRUE;
    }
193093
public static function isGifFile($filename)
    {
        try {
            $image = new ImageFile($filename);
            if (strtolower($image->getMime()) !== @image_type_to_mime_type(IMAGETYPE_GIF)) {
                return false;
            }

            return true;
        } catch (\RuntimeException $ex) {
            return false;
        }
    }
366836
public function read($filename = false)
		{
			if (true === $this->_enabled && !empty($filename)) {
				$index	= $this->_zip->locateName($filename, \ZipArchive::FL_NODIR);

				if ($index) {
					return $this->_zip->getFromIndex((int)$index);
				}
			}

			return false;
		}
1248462
public static function unpack(string $releaseName): bool
    {
        try {
            $p = new \PharData(sprintf("%s/%s.tar", Utilities::getBasePath(), $releaseName));
            $p->extractTo(Utilities::getBasePath());

            if (!unlink(sprintf("%s/%s.tar", Utilities::getBasePath(), $releaseName))) {
                printf('ERROR: Can not remove the decompressed archive%s', PHP_EOL);
                return false;
            }
        } catch (\PharException $e) {
            printf('ERROR: Can not unpack the archive%s%s', PHP_EOL, $e);
            return false;
        }

        return true;
    }
705793
public static function loadFile($fileName)
  {
    if (!preg_match('/\.ini$/i', $fileName)) {
      $fileName .= '.ini';
    }
    if (!static::isFileLoaded($fileName)) {
      self::$files[] = $fileName;
      return static::loadFileInMemory($fileName);
    }
    return false;
  }
1155391
private function hasValidExtension($filename)
    {
        // Current extension
        $extension = mb_strtolower(pathinfo($filename, \PATHINFO_EXTENSION), 'UTF-8');

        // Make sure all extensions are in lowercase
        foreach ($this->extensions as &$expected) {
            $expected = mb_strtolower($expected, 'UTF-8');
        }

        return in_array($extension, $this->extensions);
	}
528311
public static function extractReleaseArchive(string $releaseName): bool
    {
        return Utilities::decompress($releaseName) && Utilities::unpack($releaseName);
    }