Skip to content

Commit

Permalink
feat(pathlib): Add rename method
Browse files Browse the repository at this point in the history
Improve #4
  • Loading branch information
LukeSavefrogs committed Feb 13, 2024
1 parent 917a1b0 commit e2b0337
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/polyfills/pathlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,17 @@ def unlink(self, missing_ok=1 == 0):
except FileNotFoundError:
if not missing_ok:
raise

def rename(self, target):
"""Rename this file or directory to the given target.
Args:
target (str): The new name of the file or directory.
Returns:
None: No return value.
"""
_os.rename(str(Path(self._path).resolve()), str(Path(target).resolve()))

def read_bytes(self):
"""Open the file in bytes mode, read it, and close the file.
Expand Down

0 comments on commit e2b0337

Please sign in to comment.