33 lines
814 B
Markdown
33 lines
814 B
Markdown
# ResourcePath::GetFileName
|
||
|
||
```cpp
|
||
Containers::String GetFileName() const
|
||
```
|
||
|
||
获取文件名(含扩展名)。
|
||
|
||
**详细描述:**
|
||
|
||
返回路径中最后一个路径分隔符后的部分,包括文件名和扩展名。兼容 Windows (`\`) 和 Unix (`/`) 路径分隔符。
|
||
|
||
**返回:** `Containers::String`,文件名(含扩展名)
|
||
|
||
**复杂度:** O(n),n 为路径长度
|
||
|
||
**示例:**
|
||
|
||
```cpp
|
||
ResourcePath path("textures/player.png");
|
||
Containers::String name = path.GetFileName(); // "player.png"
|
||
|
||
ResourcePath path2("player.png");
|
||
Containers::String name2 = path2.GetFileName(); // "player.png"
|
||
|
||
ResourcePath path3("textures\\windows\\file.txt");
|
||
Containers::String name3 = path3.GetFileName(); // "file.txt"
|
||
```
|
||
|
||
## 相关文档
|
||
|
||
- [ResourcePath 总览](resourcepath.md) - 返回类总览
|