28 lines
621 B
Markdown
28 lines
621 B
Markdown
|
|
# ResourceFileSystem::ReadResource
|
|||
|
|
|
|||
|
|
```cpp
|
|||
|
|
Containers::Array<Core::uint8> ReadResource(const Containers::String& relativePath) const
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
读取资源文件内容。优先从归档包中读取,其次从目录中查找。
|
|||
|
|
|
|||
|
|
**参数:**
|
|||
|
|
- `relativePath` - 资源相对路径
|
|||
|
|
|
|||
|
|
**返回:** 文件内容的字节数组,读取失败返回空数组
|
|||
|
|
|
|||
|
|
**复杂度:** O(n),n 为文件大小
|
|||
|
|
|
|||
|
|
**示例:**
|
|||
|
|
|
|||
|
|
```cpp
|
|||
|
|
auto data = ResourceFileSystem::Get().ReadResource("textures/player.png");
|
|||
|
|
if (!data.Empty()) {
|
|||
|
|
// 使用数据...
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 相关文档
|
|||
|
|
|
|||
|
|
- [ResourceFileSystem 总览](filesystem.md) - 返回类总览
|