Files
XCEngine/docs/api/resources/filearchive/filearchive.md
ssdfasd 7e4c48d4f9 docs: Document stub/not-implemented methods in resources module
Fixed discrepancies between source code and documentation:
- AsyncLoader: Document Initialize() ignores workerThreadCount, Submit() doesn't do actual async loading, Update() is stub
- ResourceManager: Document UnloadUnused() and ReloadResource() are stubs
- ResourceCache: Document OnZeroRefCount() and Flush() are stubs
- ResourceDependencyGraph: Document TopologicalSort() returns empty (stub)
- ResourceFileSystem: Document GetResourceInfo() doesn't fill modifiedTime, EnumerateResources() is stub
- FileArchive: Document Enumerate() is stub
- ResourcePackageBuilder: Document AddDirectory() is stub
- ImportSettings: Document LoadFromJSON/SaveToJSON are stubs
- TextureImportSettings/MeshImportSettings: Document JSON methods are stubs
- TextureLoader/MeshLoader/MaterialLoader/ShaderLoader/AudioLoader: Document GetDefaultSettings() returns nullptr
- AudioLoader: Document ParseWAVData() is stub, Load() doesn't parse WAV headers
- ShaderLoader: Document DetectShaderType/ParseShaderSource are stubs
- MaterialLoader: Document ParseMaterialData() is stub
- Texture: Document Create() mipLevels=0 behavior, GenerateMipmaps() returns false
- Mesh: Document MeshLoader::Load() is example only
- IResourceLoader: Document GetDefaultSettings() returns nullptr for all loaders
2026-03-19 01:16:12 +08:00

85 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# FileArchive
**命名空间**: `XCEngine::Resources`
**类型**: `class` (extends IArchive)
**描述**: 文件归档封装类,用于读取归档包(如 .pak、.zip中的资源文件。
## 概述
`FileArchive` 实现了 `IArchive` 接口,提供从单个归档包文件中读取资源的功能。它维护已打开归档的路径和有效性状态。
## 头文件
```cpp
#include <XCEngine/Resources/FileArchive.h>
```
## 继承关系
```
IArchive
└── FileArchive
```
## 公共方法
### 构造与析构
| 方法 | 描述 |
|------|------|
| `FileArchive()` | 默认构造 |
| `~FileArchive()` | 析构函数,关闭归档 |
### IArchive 接口实现
| 方法 | 描述 |
|------|------|
| `bool Open(const Containers::String& path) override` | 打开归档文件 |
| `void Close() override` | 关闭归档文件 |
| `bool Read(const Containers::String& fileName, void* buffer, size_t size, size_t offset) const override` | 从归档中读取文件数据 |
| `size_t GetSize(const Containers::String& fileName) const override` | 获取归档内文件大小 |
| `bool Exists(const Containers::String& fileName) const override` | 检查文件是否存在于归档中 |
| `void Enumerate(const Containers::String& pattern, Containers::Array<Containers::String>& outFiles) const override` | 枚举归档内匹配的文件(当前为 stub |
| `bool IsValid() const override` | 检查归档是否有效 |
## 实现说明
**注意**: `Enumerate()` 当前为 stub仅清空输出数组。
### 访问器
| 方法 | 描述 |
|------|------|
| `const Containers::String& GetPath() const` | 获取归档文件路径 |
## 使用示例
```cpp
FileArchive archive;
if (archive.Open("data/resources.pak")) {
// 检查文件是否存在
if (archive.Exists("textures/player.png")) {
// 获取文件大小
size_t size = archive.GetSize("textures/player.png");
// 读取文件内容
Containers::Array<Core::uint8> buffer(size);
archive.Read("textures/player.png", buffer.Data(), size, 0);
}
// 枚举文件
Containers::Array<Containers::String> files;
archive.Enumerate("textures/*.png", files);
archive.Close();
}
```
## 相关文档
- [IArchive](../filesystem/filesystem.md) - 归档接口
- [ResourceFileSystem](../filesystem/filesystem.md) - 资源文件系统
- [Resources 总览](../resources.md) - 返回模块总览