@param string $filePath

@throws SitemapException
352402
protected function validateFilePath($filePath)
    {
        if (false === (\is_dir($filePath) && \is_writable($filePath))) {
            throw new SitemapException(
                \sprintf("Provided path '%s' does not exist or is not writable.", $filePath)
            );
        }
    }
1091769
public void updateSitePath(String sitePath) {

        String newSubTitle = getDisplayedUrl(sitePath);
        removeInvalidChildren();
        getListItemWidget().setSubtitleLabel(newSubTitle);
        String name = getName(sitePath);
        setId(name);
        getListItemWidget().setAdditionalInfoValue(1, name);
        if (getLoadState() == LoadState.LOADED) {
            for (int i = 0; i < getChildCount(); i++) {
                CmsSitemapTreeItem item = (CmsSitemapTreeItem)getChild(i);
                if ((item != null)
                    && (CmsSitemapView.getInstance().getController().getEntryById(item.getEntryId()) != null)) {
                    String path = CmsStringUtil.joinPaths(sitePath, CmsResource.getName(item.getSitePath()));
                    item.updateSitePath(path);
                }
            }
        }
        getListItemWidget().updateTruncation();
    }
886575
public function locate($filePath)
    {
        $file = $filePath;
        if (!is_file($filePath))
        {
            throw new FileException(sprintf('Invalid file! File "%s" does not exist.',
                                            $filePath));
        }

        if (!is_readable($filePath))
        {
            throw new FileException(sprintf('Invalid file! File "%s" is not readable.',
                                            $filePath));
        }

        $pathInfo = pathinfo($filePath);
        if (!isset($pathInfo['extension'])
            || !in_array($pathInfo['extension'], $this->supportedExtensions)
        )
        {
            throw new FileException(sprintf('Invalid file extension! Supported file extensions: %s',
                implode(', ', $this->supportedExtensions)));
        }

        return realpath($file);
    }
22658
protected function _ensurePathExistence($filePath) {
        $folders = explode(DIRECTORY_SEPARATOR, $filePath);
        // discard the actual file
        array_pop($folders);
        $path = implode(DIRECTORY_SEPARATOR, $folders);
        if (file_exists($path)) {
            return;
        }
        mkdir($path, 0777, true);
    }
710813
private void initializeFileData(String baseSitePath) throws CmsException {

        m_resultMap.clear();
        m_siteRootLink = OpenCms.getLinkManager().getOnlineLink(m_siteGuestCms, "/");
        m_siteRootLink = CmsFileUtil.removeTrailingSeparator(m_siteRootLink);
        m_detailPageInfos = OpenCms.getADEManager().getAllDetailPages(m_guestCms);
        for (CmsDetailPageInfo detailPageInfo : m_detailPageInfos) {
            String type = detailPageInfo.getType();
            String path = detailPageInfo.getUri();
            path = CmsFileUtil.removeTrailingSeparator(path);
            m_detailTypesByPage.put(path, type);
        }
        List<CmsAlias> siteAliases = OpenCms.getAliasManager().getAliasesForSite(
            m_siteGuestCms,
            m_siteGuestCms.getRequestContext().getSiteRoot());
        for (CmsAlias alias : siteAliases) {
            if (isAliasBelowBaseFolder(alias) && (alias.getMode() == CmsAliasMode.page)) {
                CmsUUID aliasId = alias.getStructureId();
                m_pageAliasesBelowBaseFolderByStructureId.put(aliasId, alias);
            }
        }

    }
1053678
public static function loadContextFromFile(string $filePath): ContextInterface
    {
        if(!file_exists($filePath)){
            throw new Exception\FileNotFoundException('Context file not found: '.$filePath, 404, null, $filePath);
        }

        $contents = file_get_contents($filePath);
        $context_array = json_decode($contents, true);

        if($context_array === null){
            throw new Exception\MalformedJsonException('JSON sintax error.');
        }

        return new self($context_array);
    }
1119657
public static function setDefaultMagicFile($filePath = null)
    {
        if (!is_null($filePath) && !file_exists($filePath)) {
            throw new FileNotFoundException('File does not exist or is not readable: ' . $filePath);
        }
        self::$defaultMagicFile = $filePath;
    }
985309
public void delete(String sitePath) {

        CmsClientSitemapEntry entry = getEntry(sitePath);
        CmsClientSitemapEntry parent = getEntry(CmsResource.getParentFolder(entry.getSitePath()));
        CmsSitemapChange change = new CmsSitemapChange(entry.getId(), entry.getSitePath(), ChangeType.delete);
        change.setParentId(parent.getId());
        change.setDefaultFileId(entry.getDefaultFileId());
        CmsSitemapClipboardData data = CmsSitemapView.getInstance().getController().getData().getClipboardData().copy();
        if (!entry.isNew()) {
            data.addDeleted(entry);
            removeDeletedFromModified(entry, data);
        }
        change.setClipBoardData(data);
        CmsDetailPageTable detailPageTable = CmsSitemapView.getInstance().getController().getData().getDetailPageTable();
        CmsUUID id = entry.getId();
        if (detailPageTable.contains(id)) {
            CmsDetailPageTable copyTable = detailPageTable.copy();
            copyTable.remove(id);
            change.setDetailPageInfos(copyTable.toList());
        }
        commitChange(change, null);
    }
840078
public function addMetaFile($filepath)
    {
        $this->metadata = (array)CompiledYamlFile::instance($filepath)->content();
        $this->merge($this->metadata);
    }
929135
private static void loadFile(String filePath) {
        final Path path = FileSystems.getDefault().getPath(filePath);

        try {
            data.clear();
            data.load(Files.newBufferedReader(path));
        } catch(IOException e) {
            LOG.warn("Exception while loading " + path.toString(), e);
        }
    }
408937
public static function subscribers(string $filePath = null)
    {
        if (is_file($filePath)) {
            /** @noinspection PhpIncludeInspection */
            $subscribers = require_once $filePath;

            $subscribers = is_array($subscribers) ? $subscribers : [];

            foreach ($subscribers as $subscriber) {
                Event::register(IOC::resolve($subscriber));
            }

            Event::dispatch('minimal.loaded.subscribers',
                [$filePath, $subscribers]);
        }
    }
791385
public function setLogFile($filePath)
    {
        if ($this->logFile != $filePath && $this->fp) {
            @fclose($this->fp);
            $this->fp = null;
        }
        $logDir = dirname($filePath);
        if (!file_exists($logDir)) {
            @mkdir($logDir, 0755, true);
        }

        if (!file_exists($logDir)) {
            throw new Exception(sprintf('Can\'t create log directory "%s".', $logDir), 'logger');
        }

        if (!$this->fp = @fopen($filePath, 'a+')) {
            throw new Exception(sprintf('Can\'t create log file "%s".', $filePath), 'logger');
        }

        $this->logFile = $filePath;
        return $this;
    }
645945
protected function loadJsonConfigFile(string $fileKey, string $filePath)
    {
        $json   = file_get_contents($filePath);
        $config = json_decode($json);

        if ($config === null) {
            throw new Exception(
                json_last_error_msg(),
                $this::ERR_JSON_PARSE
            );
        }

        $this->config[$fileKey] = $config;
    }
796800
protected function createOutputPlaceholderFile()
    {
        $filePath = $this->getFullFilePath();

        if (true === \file_exists($filePath)) {
            throw new SitemapException(
                \sprintf('Cannot create sitemap. File \'%s\' already exists.', $filePath)
            );
        }

        return \touch($filePath);
    }
1151899
private function replaceDummyInFile($filePath)
    {
        $fileSource = File::get($filePath);
        $fileContent = str_replace(array_keys($this->dummyReplacements), array_values($this->dummyReplacements), $fileSource);
        $writeFile = File::put($filePath, $fileContent);
        if ($writeFile === false) {
            throw new \Exception("Error writing to file " . $filePath);
        }
    }
213967
private function writeFile($filePath, $data)
    {
        $fh = fopen($filePath, 'w+');
        fwrite($fh, $data);
        fclose($fh);
    }
899702
public static function parseStations($filePath)
    {
        if (DIRECTORY_SEPARATOR == '\\')
            $filePath = str_replace('/', '\\', $filePath);
        ini_set('display_errors', 1);
        error_reporting(E_ALL);
        $stationConf = DWDConfiguration::getStationConfiguration();
        $stations = array();

        if (file_exists($filePath)) {
            $handle = fopen($filePath, "r");
            if ($handle) {
                //skips the first N lines of input, requires the file handle.
                self::skipDescriptionLines($stationConf->skipLines, $handle);
                while (($line = fgets($handle)) !== false) {
                    $line = mb_convert_encoding($line, "UTF-8", "iso-8859-1");

                    // eliminate multiple spaces, replace by single space
                    $output = preg_replace('!\s+!', ' ', $line);
                    //remove trailing and leading spaces.
                    $output = trim($output, ' ');

                    // process the line read - split by spaces
                    // stationId, from, until, stationHeight, lat, long, station name, state
                    // Station name can contain spaces and needs further processing, thus we limit to keep station name + state
                    // in one field
                    $split = explode(" ", $output, 7);
                    $name = explode(" ", $split[count($split) - 1]);
                    //last cell contains the county name.
                    $county = $name[count($name) - 1];
                    // merge all other contents of the name, glue them together with spaces.
                    $nameSlice = array_slice($name, 0, count($name) - 1);
                    $name = implode(" ", $nameSlice);

                    //evtl. array_filter
                    $from = Carbon::createFromFormat($stationConf->dateFormat, $split[1], 'UTC');
                    $until = Carbon::createFromFormat($stationConf->dateFormat, $split[2], 'UTC');

                    $station = new DWDStation($split[0], $from, $until,
                        $split[3], $split[4], $split[5], $name, $county,
                        $stationConf->activeRequirementDays);
                    $stations[] = $station;

                }

                fclose($handle);
            } else {
                throw new DWDLibException("Error opening the file: " . $filePath);
            }
        } else
            throw new DWDLibException("File does not exist - path: " . $filePath);

        return $stations;
    }