Skip to content

Commit

Permalink
New fs method: Storage.relative_path(name)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nayjest committed Nov 19, 2024
1 parent ed287d8 commit e28a76f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions microcore/file_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def abs_path(self, name: str | Path) -> Path:
return Path(name)
return self.path / name

def relative_path(self, name: str | Path) -> Path:
"""
Returns the relative path of the file or directory within the storage path.
"""
return Path(name).relative_to(self.path)

def read(self, name: str | Path, encoding: str = None):
name = str(name)
encoding = encoding or self.default_encoding
Expand Down

0 comments on commit e28a76f

Please sign in to comment.