This commit is contained in:
blueloveTH 2023-04-28 13:54:27 +08:00
parent 6031bf4799
commit 46b1b1b900
2 changed files with 9 additions and 0 deletions

View File

@ -38,3 +38,7 @@ Joins the given paths together.
### `os.path.exists(path: str)`
Check if the given path exists.
### `os.path.basename(path: str)`
Returns the basename of the given path.

View File

@ -169,6 +169,11 @@ inline void add_module_os(VM* vm){
bool exists = std::filesystem::exists(path);
return VAR(exists);
});
vm->bind_func<1>(path_obj, "basename", [](VM* vm, ArgsView args){
std::filesystem::path path(CAST(Str&, args[0]).sv());
return VAR(path.filename().string());
});
}
} // namespace pkpy