blueloveTH 2 ani în urmă
părinte
comite
46b1b1b900
2 a modificat fișierele cu 9 adăugiri și 0 ștergeri
  1. 4 0
      docs/modules/os.md
  2. 5 0
      src/io.h

+ 4 - 0
docs/modules/os.md

@@ -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.

+ 5 - 0
src/io.h

@@ -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