Retrieves a file for the controller by querying the nearest station.
@param AbstractHourlyService $service
@param DWDStation $nearestStation
@param bool $forceDownloadFile
@return string filePath
12159
public function retrieveFile(AbstractHourlyService $service, DWDStation $nearestStation, $forceDownloadFile = false)
    {
        $config = DWDConfiguration::getConfiguration();
        $ftpConfig = $config->ftp;


        $fileName = $service->getFileName($nearestStation->getId());
        $ftpPath = $service->getFileFTPPath($nearestStation->getId());
        $localPath = $service->getFilePath($fileName);
        DWDUtil::log(self::class, '$fileName=' . $fileName);
        DWDUtil::log(self::class, '$ftpPath=' . $ftpPath);
        DWDUtil::log(self::class, '$localPath=' . $localPath);

        //get file.
        $ftp_connection = ftp_connect($ftpConfig->url);
        //ftp_set_option($ftp_connection, FTP_TIMEOUT_SEC, 9000);
        $files = array();
        if (file_exists($localPath)) {
            $lastModifiedStationFile = Carbon::createFromFormat('U', (filemtime($localPath)));
        }
        //check if the date on the old file is older than 1 day, else return the old path.
        // download can be forced with the optional parameter.
        if ($forceDownloadFile || !file_exists($localPath)
            || (isset($lastModifiedStationFile) && $lastModifiedStationFile->diffInDays(Carbon::now()) >= 1)
        ) {
            //echo "<p>Controller::retrieveFile >> load new zip!</p>";
            $path = pathinfo($localPath);
            if (!is_dir($path['dirname'])) {

                mkdir($path['dirname'], 0755, true);
            }

            if (ftp_login($ftp_connection, $ftpConfig->userName, $ftpConfig->userPassword)) {
//                DWDUtil::log(self::class, 'File "' . $ftpPath . '"exists on server? ' . ftp_size($ftp_connection, $ftpPath));
                if (ftp_size($ftp_connection, $ftpPath) > -1 && ftp_get($ftp_connection, $localPath, $ftpPath, FTP_BINARY)) {
                    $files[] = $localPath;
                } else {
                    return null;
                }

                ftp_close($ftp_connection);
                return $localPath;
            }
        }

        return $localPath;
    }
369514
public static function service(string $class, bool $forceNew = false)
    {
        /** @var Container $container */
        $container = static::getContainer();

        if (!$forceNew && $container->has($class)) {
            return $container->get($class);
        }

        return $container->createSharedObject($class);
    }
1085695
public function getFile(PayoneGetFileTransfer $getFileTransfer)
    {
        $responseContainer = new GetFileResponseContainer();
        $paymentEntity = $this->findPaymentByFileReferenceAndCustomerId(
            $getFileTransfer->getReference(),
            $getFileTransfer->getCustomerId()
        );

        if ($paymentEntity) {
            /** @var \SprykerEco\Zed\Payone\Business\Payment\MethodMapper\DirectDebit $paymentMethodMapper */
            $paymentMethodMapper = $this->getRegisteredPaymentMethodMapper(PayoneApiConstants::PAYMENT_METHOD_DIRECT_DEBIT);
            $requestContainer = $paymentMethodMapper->mapGetFile($getFileTransfer);
            $this->setStandardParameter($requestContainer);
            $rawResponse = $this->executionAdapter->sendRequest($requestContainer);
            $responseContainer->init($rawResponse);
        } else {
            $this->setAccessDeniedError($responseContainer);
        }

        $getFileTransfer->setRawResponse($responseContainer->getRawResponse());
        $getFileTransfer->setStatus($responseContainer->getStatus());
        $getFileTransfer->setErrorCode($responseContainer->getErrorcode());
        $getFileTransfer->setCustomerErrorMessage($responseContainer->getCustomermessage());
        $getFileTransfer->setInternalErrorMessage($responseContainer->getErrormessage());

        return $getFileTransfer;
    }
763214
public function get($service, $headers = null, $data = null)
	{
		return $this->customRequest($service, 'GET', $headers, $data);
	}
641335
public static final function toServiceFile(string $serviceName): string
    {
        $serviceFile = sprintf('%s/app/service/%s/%s.php', APP_DIR, $serviceName, $serviceName);
        if (!file_exists($serviceFile) && (
            $serviceName == (Service::SERVICE_MAIN . Service::SERVICE_NAME_SUFFIX)
                || $serviceName == (Service::SERVICE_FAIL . Service::SERVICE_NAME_SUFFIX))) {
            $serviceFile = sprintf('%s/app/service/_default/%s/%s.php', APP_DIR, $serviceName, $serviceName);
        }

        return $serviceFile;
    }
466738
public function get($service)
    {
        return $this->has($service) ? $this->container->get($service) : null;
    }
1003061
def get_fileservice_dir():
    
    conf = getattr(settings, 'FILESERVICE_CONFIG', {})
    dir = conf.get('store_dir', './fileservice_store')
    return os.path.normpath(dir) + os.sep
1172059
private static <T> Optional<T> loadFirst(final Class<T> service) {
        return of(ServiceLoader.load(service).iterator()).filter(Iterator::hasNext).map(Iterator::next);
    }
727502
public function getUploadedFlyFile($serial)
    {
        $path = $this->getUserDirectoryHash() . '/';
        if (filter_var($serial, FILTER_VALIDATE_URL)) {
            // Getting the File instance of the file url.
            $fakeFile = $this->getSerializer()->unserializeFile($serial);

            // Filesystem hack check.
            if ($fakeFile->getFileSystemId() !== $this->getUploadFSid()) {
                throw new \common_exception_NotAcceptable(
                    'The uploaded file url contains a wrong filesystem id!' .
                    '(Expected: `' . $this->getUploadFSid() . '` Actual: `' . $fakeFile->getFileSystemId() . '`)'
                );
            }

            $path .= $fakeFile->getBasename();
        }
        else {
            $path .= $serial;
        }

        $realFile = $this->getUploadDir()->getFile($path);
        if ($realFile->exists()) {
            return $realFile;
        }

        return null;
    }
1167153
public function getTranslationFile(TransUnitInterface & $transUnit, $locale)
    {
        $file = null;
        foreach ($transUnit->getTranslations() as $translation) {
            if (null !== $file = $translation->getFile()) {
                break;
            }
        }

        //if we found a file
        if ($file !== null) {
            //make sure we got the correct file for this locale and domain
            $name = sprintf('%s.%s.%s', $file->getDomain(), $locale, $file->getExtention());
            $file = $this->fileManager->getFor($name, $this->kernelRootDir.DIRECTORY_SEPARATOR.$file->getPath());
        }

        return $file;
    }
758495
public function forceDownload($filename = null, $filemime = 'application/octet-stream')
    {
        // Force mime
        $this->filemime = $filemime;
        $this->download($filename);
    }
585753
public function getDirectory(): FilePathInterface
    {
        return new self($this->myIsAbsolute, $this->myAboveBaseLevel, $this->myDrive, $this->myDirectoryParts, null);
    }
248650
public function copyFileToService($from, $destination, $service)
    {
        if (!file_exists($from)) {
            throw new EngineRuntimeException(
                'The file path does not exist.'
            );
        }
        $container = $this->getServiceContainerId($service);

        return $this->_exec("docker cp {$from} {$container}:{$destination}");
    }
415639
public function get_url($forcedownload=false, $https=false) {
        if (!$this->is_readable()) {
            return null;
        }

        if ($this->is_directory()) {
            return null;
        }

        $this->urlbase;
        $contextid = $this->lf->get_contextid();
        $component = $this->lf->get_component();
        $filearea  = $this->lf->get_filearea();
        $itemid    = $this->lf->get_itemid();
        $filepath  = $this->lf->get_filepath();
        $filename  = $this->lf->get_filename();

        if ($this->itemidused) {
            $path = '/'.$contextid.'/'.$component.'/'.$filearea.'/'.$itemid.$filepath.$filename;
        } else {
            $path = '/'.$contextid.'/'.$component.'/'.$filearea.$filepath.$filename;
        }
        return file_encode_url($this->urlbase, $path, $forcedownload, $https);
    }
1366409
public function getLocalFilePath($filename, $route, &$isTempFile, $includeStoragePath = false)
  {
    $isTempFile = false;

    if($this->Config->get('filesystems.default') == 'gcs')
    {
      $isTempFile = true;

      $this->Storage->disk('local')->put('//temp/' . $filename, $this->Storage->read($route));

      $route = 'temp/' . $filename;
    }

    if($includeStoragePath)
    {
      return storage_path('app') . '/' . $route;
    }

    return $route;
  }
346354
public static function GetService($wsdl, $forceNuSoap = false)
	{
		if (extension_loaded("soap") && !$forceNuSoap)
		{
			Debug::PrintValue("Local");
			$client = new SoapClient($wsdl);
			return $client;
		}
		else 
		{
			Debug::PrintValue("NuSoap");
			if (!SoapClientWrapper::$_readed)
			{
				//Debug::PrintValue("Read NuSoap");
		    	require_once("nusoap.php");
		    	SoapClientWrapper::$_readed = true;
			}
			$client = new nusoap_client($wsdl, 'wsdl');
			$proxy = $client->getProxy();
			return $proxy;
		}
	}
548232
public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, array $options = null) {
        $reference = $this->unpack_reference($storedfile->get_reference());

        $maxcachesize = $this->max_cache_bytes();
        if (empty($maxcachesize)) {
            // Always cache the file, regardless of size.
            $cachefile = true;
        } else {
            // Size available. Only cache if it is under maxcachesize.
            $cachefile = $storedfile->get_filesize() < $maxcachesize;
        }

        if (!$cachefile) {
            \core\session\manager::write_close();
            header('Location: ' . $this->get_file_download_link($reference->url));
            die;
        }

        try {
            $this->import_external_file_contents($storedfile, $this->max_cache_bytes());
            if (!is_array($options)) {
                $options = array();
            }
            $options['sendcachedexternalfile'] = true;
            \core\session\manager::write_close();
            send_stored_file($storedfile, $lifetime, $filter, $forcedownload, $options);
        } catch (moodle_exception $e) {
            // Redirect to Dropbox, it will show the error.
            // Note: We redirect to Dropbox shared link, not to the download link here!
            \core\session\manager::write_close();
            header('Location: ' . $reference->url);
            die;
        }
    }