Files
XCEngine/docs/api/resources/resourcepath/getdirectory.md

33 lines
783 B
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.
# ResourcePath::GetDirectory
```cpp
Containers::String GetDirectory() const
```
获取目录部分。
**详细描述:**
返回路径中最后一个路径分隔符之前的所有内容,即目录路径。兼容 Windows (`\`) 和 Unix (`/`) 路径分隔符。
**返回:** `Containers::String`,目录路径
**复杂度:** O(n)n 为路径长度
**示例:**
```cpp
ResourcePath path("textures/player.png");
Containers::String dir = path.GetDirectory(); // "textures"
ResourcePath path2("textures/subfolder/player.png");
Containers::String dir2 = path2.GetDirectory(); // "textures/subfolder"
ResourcePath path3("player.png");
Containers::String dir3 = path3.GetDirectory(); // ""
```
## 相关文档
- [ResourcePath 总览](resourcepath.md) - 返回类总览