@param FileInterface $file

@return bool
167703
public function isDeleteAllowed(FileInterface $file)
    {
        if (!$this->authorizationChecker->isGranted('ROLE_SUPER_ADMIN') && !$this->authorizationChecker->isGranted('FILE_DELETE', $file->getVolume()->findFolder($file->getFolderId()))) {
            return false;
        }

        if ($this->deletePolicy === 'delete_all') {
            return true;
        }

        $fileUsageRepository = $this->entityManager->getRepository('PhlexibleMediaManagerBundle:FileUsage');
        $fileUsages = $fileUsageRepository->findBy(['file' => $file]);

        foreach ($fileUsages as $fileUsage) {
            if (in_array($fileUsage->getStatus(), [FileUsage::STATUS_ONLINE, FileUsage::STATUS_LATEST])) {
                return false;
            }
            if ($fileUsage->getStatus() === FileUsage::STATUS_OLD && $this->deletePolicy === 'hide_old') {
                return false;
            }
        }

        return true;
    }
966955
public function loadIgnore(string $file)
    {
        if (file_exists($this->getThemePath() . $this->sanitizeFileName($file))) {
            return $this->load($file);
        }

        return false;
    }
526725
protected function hasNotBeenAdded(ResourceInterface $resource): bool
    {
        return isset($this->addedResources[$resource->getId()][$resource->getType()]) === false;
    }
592361
public function name(FileInterface $file)
    {
        $bytes = random_bytes(256 / 8);

        return rtrim(strtr(base64_encode($bytes), '+/', '-_'), '=').'.'.$file->getExtension();
    }
1056535
protected function evaluateFile(FileInterface $file) {
    $uri = $file->getFileUri();
    $scheme = $this->fileSystem->uriScheme($uri);
    return !empty($this->configuration['filesystems'][$scheme]);
  }
172879
public function perform(FilesInterface $files)
    {
        if (!$this->verifyConfigured()) {
            return;
        }

        if (empty($this->migrator->getMigrations())) {
            $this->writeln("<comment>No migrations were found.</comment>");

            return;
        }

        $table = $this->table(['Migration', 'Filename', 'Created at', 'Executed at']);
        foreach ($this->migrator->getMigrations() as $migration) {
            $filename = (new \ReflectionClass($migration))->getFileName();

            $state = $migration->getState();

            $table->addRow([
                $state->getName(),
                '<comment>'
                . $files->relativePath($filename, $this->config->getDirectory())
                . '</comment>',
                $state->getTimeCreated()->format('Y-m-d H:i:s'),
                $state->getStatus() == State::STATUS_PENDING
                    ? self::PENDING
                    : '<info>' . $state->getTimeExecuted()->format('Y-m-d H:i:s') . '</info>'
            ]);
        }

        $table->render();
    }
965193
protected function _removeFile($file)
    {
        $_file = new File($file);

        if ($_file->exists()) {
            $_file->delete();

            $folder = $_file->folder();
            if (count($folder->find()) === 0) {
                $folder->delete();
            }
            return true;
        }
        return false;
    }
633057
public function validate(EventInterface $event)/*# : bool */
    {
        /* @var ResultInterface $result */
        $result = $event->getParam('result');
        $params = $result->getParameters();

        if ($params['id'] < 2000) {
            $result->setStatus(Status::PRECONDITION_FAILED);
            return false;
        }
        return true;
    }
417742
public function setFile(\Enhavo\Bundle\MediaBundle\Model\FileInterface $file = null)
    {
        $this->file = $file;

        return $this;
    }
550846
public function hasLoaded(string $file) : bool
    {
        $file = $this->sanitizeFileName($file);
        return isset($this->loaded[$file]);
    }
612168
public function hasInterface($interface): bool {
		if ($interface instanceof PhpInterface) {
			return $this->interfaces->contains($interface->getName())
				|| $this->interfaces->contains($interface->getQualifiedName());
		}

		return $this->interfaces->contains($interface) || $this->hasInterface(new PhpInterface($interface));
	}
8549
public function showFile(FileInterface $file, $userId)
    {
        $event = new FileEvent($file);
        if ($this->eventDispatcher->dispatch(VolumeEvents::BEFORE_SHOW_FILE, $event)->isPropagationStopped()) {
            throw new IOException("Show file {$file->getName()} cancelled.");
        }

        $this->driver->showFile($file);

        $event = new FileEvent($file);
        $this->eventDispatcher->dispatch(VolumeEvents::SHOW_FILE, $event);

        return $file;
    }
230340
public function isAnimatedGif(FileInterface $file): bool
    {
        if ($file->getMimeType() === 'image/gif') {
            $filecontents = file_get_contents($file->getForLocalProcessing());
            $strLoc = 0;
            $count = 0;

            // There is no point in continuing after we find a 2nd frame
            while ($count < 2) {
                $where1 = strpos($filecontents, "\x00\x21\xF9\x04", $strLoc);
                if ($where1 === false) {
                    break;
                }
                $strLoc = $where1 + 1;
                $where2 = strpos($filecontents, "\x00\x2C", $strLoc);
                if ($where2 === false) {
                    break;
                }
                if ($where1 + 8 == $where2) {
                    $count++;
                }
                $strLoc = $where2 + 1;
            }

            return $count > 1;
        }

        return false;
    }
1101295
public function fileExists(AbstractFile $file)
    {
        $fullPath = $this->getFullPath($file->isUploaded() ? 'tmp' : 'upload_files', $file->getPath());

        return $this->fs->exists($fullPath);
    }
111577
public function get(CacheableInterface $item)
    {
        $targetFile = $this->getTargetFile($item->getHashKey());

        $return = false;
        if (file_exists($targetFile)) {
            if ($item->getTtl() > 0 && ((filemtime($targetFile) + $item->getTtl()) < time())) {
                $this->remove($item);
            } else {
                $return = unserialize(file_get_contents($targetFile, false, null, strlen(self::STR_PREFIX)));
            }
        }

        return $return;
    }
313830
public function supportsEntity(EntityInterface $entity): bool
    {
        foreach ($this->mappers as $mapper) {
            if ($mapper->supportsEntity($entity)) {
                return true;
            }
        }

        return false;
    }
616780
public function file(FileInterface $storage = null)
    {
        if ($storage) {
            $this->storage = $storage;
        }

        return $this->storage;
    }