@param string $containerName
@param string $filePath
@param string|null $relativePath

@return bool
429375
public function deleteFile($containerName, $filePath, $relativePath)
    {
        return $this->getFactory()
            ->createStorage($containerName)
            ->deleteFile($containerName, $filePath, $relativePath);
    }
1076823
public function getFile($relativePath)
    {
        $fileKey = $this->getFileKey($this->getAbsolutePath($relativePath));

        return new File($fileKey, $this);
    }
439595
public function handle($absolutePath, $relativePath)
    {
        //adapt the file path before comparing them to expected files
        $relativePathAdapted = preg_replace('/^\.\//', '', $relativePath);
        return $this->portableItemParser->importPortableElementFile($absolutePath, $relativePathAdapted);
    }
171321
public function deleteFile($containerName, $fileName, $relativePath)
    {
        return $this->fileUploadFacade->deleteFile($containerName, $fileName, $relativePath);
    }
368461
public function uploadFile(string $dirPath, string $fileName): bool
    {
        try {
            if (!$this->filesystem->createDir($dirPath)) {
                return false;
            }

            $targetFilePath = $dirPath . DIRECTORY_SEPARATOR . $fileName;

            if ($this->filesystem->has($targetFilePath)) {
                $this->addError('', "File by path `{$targetFilePath}` already exists.");

                return false;
            }

            $contentResource = $this->getFileContent();
            if ($contentResource === null) {
                return false;
            }

            return $this->filesystem->writeStream($targetFilePath, $contentResource);
        } catch (\Exception $e) {
            return false;
        }
    }
511827
public function loadContainer($containerPath)
    {
        $containerPath = realpath($containerPath);

        if (false === $containerPath) {
            return false;
        }

        $this->container = new ContainerBuilder();

        try {
            $loader = new XmlFileLoader($this->container, new FileLocator(dirname($containerPath)));
            $loader->load(basename($containerPath));

            return true;
        } catch (\Exception $e) {
            return false;
        }
    }
1213678
@Nullable
  static SourceFile getRelativePath(String baseFilePath, String relativePath) {
    return SourceFile.fromPath(
        FileSystems.getDefault().getPath(baseFilePath).resolveSibling(relativePath).normalize(),
        UTF_8);
  }
17804
public function create($filePath = null, $mode = 'wb')
    {
        $filePath = isset($filePath) ? $filePath : $this->filePath;
        $dir = dirname($filePath);

        if ( ! is_writable($dir)) {
            if ( ! file_exists($dir)) {
                mkdir($dir, 0777, true);
            }
        }

        if ( ! $fp = @fopen($filePath, $mode)) {
            return false;
        }

        parent::__construct($filePath);

        return $fp;
    }
1264451
public function isApplicable($relativePath)
    {
        $xincluded = array();
        /** @var Element $xincludeElement */
        foreach ($this->getQtiItem()->getComposingElements('oat\taoQtiItem\model\qti\Xinclude') as $xincludeElement) {
            $xincluded[] = $xincludeElement->attr('href');
            \common_Logger::i("Xinclude component found in resource '" .
                $this->getQtiItem()->getIdentifier() . "' with href '" . $xincludeElement->attr('href') . "'.");
        }

        return in_array($relativePath, $xincluded);
    }
384255
public function fileExists($containerName, $fileName, $relativePath)
    {
        $fullFileName = $this->getFullFileName($containerName, $fileName, $relativePath);

        return $this->filesystem->has($fullFileName);
    }
465118
protected function getFullFileName($containerName, $fileName, $relativePath)
    {
        if ($relativePath === null) {
            $relativePath = '';
        } else {
            $relativePath = trim($relativePath, '/');
            $relativePath = $relativePath . '/';
        }

        return sprintf('%s/%s%s', $containerName, $relativePath, $fileName);
    }
550237
public function deleteFile($containerName, $fileName, $relativePath)
    {
        $fullFileName = $this->getFullFileName($containerName, $fileName, $relativePath);

        return $this->filesystem->delete($fullFileName);
    }
1166392
public function loadFile($filePath)
    {
        if ($filePath instanceof \SplFileInfo) {
            $filePath = $filePath->getRealPath();
        }

        if (isset($this->sourceFileDirectory)) {
            if (is_file($this->sourceFileDirectory . $filePath)) {
                $filePath = $this->sourceFileDirectory . $filePath;
            }
        }

        if (is_file($filePath)) {
            $this->sourceFilePath = realpath($filePath);
            $this->sourceFileDirectory = pathinfo($this->sourceFilePath, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR;

            return $this->loadString(file_get_contents($filePath));
        }

        return false;
    }
397016
final private static function getDirectoryStructureDo($relativePath, $rootDirectory, $exclude3rdParty)
    {
        $thisRoot = $rootDirectory;
        if ($relativePath !== '') {
            $thisRoot .= '/'.$relativePath;
        }
        $subDirs = array();
        $hDir = @opendir($thisRoot);
        if ($hDir === false) {
            throw new \Exception("Unable to open directory $rootDirectory");
        }
        while (($entry = @readdir($hDir)) !== false) {
            if ($entry[0] === '.') {
                continue;
            }
            $fullPath = $thisRoot.'/'.$entry;
            if (!is_dir($fullPath)) {
                continue;
            }
            if ($exclude3rdParty) {
                if (($entry === 'vendor') || preg_match('%/libraries/3rdparty$%', $fullPath)) {
                    continue;
                }
            }
            $subDirs[] = $entry;
        }
        @closedir($hDir);
        $result = array();
        foreach ($subDirs as $subDir) {
            $rel = ($relativePath === '') ? $subDir : "$relativePath/$subDir";
            $result = array_merge($result, static::getDirectoryStructureDo($rel, $rootDirectory, $exclude3rdParty));
            $result[] = $rel;
        }

        return $result;
    }
163745
public function pathToClass($relativePath)
    {
        if (strpos($relativePath, '/') !== false) {
            $relativePath = dirname($relativePath).'/'.basename($relativePath, '.php');
        } else {
            $relativePath = basename($relativePath, '.php');
        }

        return str_replace('/', '\\', $relativePath);
    }
1339332
public function isTrustedResourceDir($filepath)
    {
        $_template = false;
        $_config = false;
        $_secure = false;

        $_template_dir = $this->smarty->getTemplateDir();
        $_config_dir = $this->smarty->getConfigDir();

        // check if index is outdated
        if ((!$this->_template_dir || $this->_template_dir !== $_template_dir)
            || (!$this->_config_dir || $this->_config_dir !== $_config_dir)
            || (!empty($this->secure_dir) && (!$this->_secure_dir || $this->_secure_dir !== $this->secure_dir))
        ) {
            $this->_resource_dir = array();
            $_template = true;
            $_config = true;
            $_secure = !empty($this->secure_dir);
        }

        // rebuild template dir index
        if ($_template) {
            $this->_template_dir = $_template_dir;
            foreach ($_template_dir as $directory) {
                $directory = realpath($directory);
                $this->_resource_dir[$directory] = true;
            }
        }

        // rebuild config dir index
        if ($_config) {
            $this->_config_dir = $_config_dir;
            foreach ($_config_dir as $directory) {
                $directory = realpath($directory);
                $this->_resource_dir[$directory] = true;
            }
        }

        // rebuild secure dir index
        if ($_secure) {
            $this->_secure_dir = $this->secure_dir;
            foreach ((array) $this->secure_dir as $directory) {
                $directory = realpath($directory);
                $this->_resource_dir[$directory] = true;
            }
        }

        $_filepath = realpath($filepath);
        $directory = dirname($_filepath);
        $_directory = array();
        while (true) {
            // remember the directory to add it to _resource_dir in case we're successful
            $_directory[$directory] = true;
            // test if the directory is trusted
            if (isset($this->_resource_dir[$directory])) {
                // merge sub directories of current $directory into _resource_dir to speed up subsequent lookup
                $this->_resource_dir = array_merge($this->_resource_dir, $_directory);

                return true;
            }
            // abort if we've reached root
            if (($pos = strrpos($directory, DS)) === false || !isset($directory[1])) {
                break;
            }
            // bubble up one level
            $directory = substr($directory, 0, $pos);
        }

        // give up
        throw new SmartyException("directory '{$_filepath}' not allowed by security setting");
    }
458280
public function fileExists($containerName, $fileName, $relativePath)
    {
        return $this->fileUploadFacade->fileExists($containerName, $fileName, $relativePath);
    }