Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
ContainedFileReader.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
7#include <PhosphorFsLoader/phosphorfsloader_export.h>
8
9#include <QtCore/QByteArray>
10#include <QtCore/QString>
11#include <QtCore/QtGlobal>
12
13#include <optional>
14
16
20inline constexpr qsizetype kMaxDeclaredPathLength = 4096;
21
24{
26 QByteArray bytes;
29 QString path;
30};
31
65[[nodiscard]] PHOSPHORFSLOADER_EXPORT std::optional<ContainedFile>
66readFileWithinDirectory(const QString& declaredPath, const QString& directory, AbsolutePathPolicy policy,
67 qint64 maxBytes, QString* error = nullptr);
68
69} // namespace PhosphorFsLoader
Definition ContainedFileReader.h:15
AbsolutePathPolicy
What to do with a declared path that is already absolute.
Definition PackPathGuard.h:16
PHOSPHORFSLOADER_EXPORT std::optional< ContainedFile > readFileWithinDirectory(const QString &declaredPath, const QString &directory, AbsolutePathPolicy policy, qint64 maxBytes, QString *error=nullptr)
Read declaredPath, resolved against directory, refusing anything that escapes the directory or is not...
constexpr qsizetype kMaxDeclaredPathLength
Longest declared path readFileWithinDirectory accepts, in UTF-16 code units.
Definition ContainedFileReader.h:20
What readFileWithinDirectory hands back on success.
Definition ContainedFileReader.h:24
QString path
The cleaned absolute path that was opened, in the same lexical form resolveWithinDirectory returns,...
Definition ContainedFileReader.h:29
QByteArray bytes
The whole file, never more than the caller's limit.
Definition ContainedFileReader.h:26