mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
update os
This commit is contained in:
parent
c5e055e1a8
commit
5eaef2c900
@ -43,6 +43,18 @@ Check if the given path exists.
|
||||
|
||||
Returns the basename of the given path.
|
||||
|
||||
### `os.path.isdir(path: str)`
|
||||
|
||||
Check if the given path is a directory.
|
||||
|
||||
### `os.path.isfile(path: str)`
|
||||
|
||||
Check if the given path is a file.
|
||||
|
||||
### `os.path.abspath(path: str)`
|
||||
|
||||
Returns the absolute path of the given path.
|
||||
|
||||
|
||||
## Other functions
|
||||
|
||||
|
17
src/io.cpp
17
src/io.cpp
@ -226,6 +226,23 @@ void add_module_os(VM* vm){
|
||||
std::filesystem::path path(CAST(Str&, args[0]).sv());
|
||||
return VAR(path.filename().string());
|
||||
});
|
||||
|
||||
vm->bind_func<1>(path_obj, "isdir", [](VM* vm, ArgsView args){
|
||||
std::filesystem::path path(CAST(Str&, args[0]).sv());
|
||||
bool isdir = std::filesystem::is_directory(path);
|
||||
return VAR(isdir);
|
||||
});
|
||||
|
||||
vm->bind_func<1>(path_obj, "isfile", [](VM* vm, ArgsView args){
|
||||
std::filesystem::path path(CAST(Str&, args[0]).sv());
|
||||
bool isfile = std::filesystem::is_regular_file(path);
|
||||
return VAR(isfile);
|
||||
});
|
||||
|
||||
vm->bind_func<1>(path_obj, "abspath", [](VM* vm, ArgsView args){
|
||||
std::filesystem::path path(CAST(Str&, args[0]).sv());
|
||||
return VAR(std::filesystem::absolute(path).string());
|
||||
});
|
||||
}
|
||||
#else
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user