Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/androidemu/vfs/file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,15 @@ def translate_path(self, filename) -> pathlib.Path:

file_path = self._root_path.joinpath(filename).resolve()

if not file_path.is_relative_to(self._root_path):
raise RuntimeError("Emulator tried to read outside vfs ('%s' not in '%s')." % (file_path, self._root_path))
# when system is macos, the pathlib.Path return was PosixPath, The PosixPath object does not have the is_relative_to method
if os.name == "posix":
try:
file_path.relative_to(self._root_path)
except:
raise RuntimeError("Emulator tried to read outside vfs ('%s' not in '%s')." % (file_path, self._root_path))
else:
if not file_path.is_relative_to(self._root_path):
raise RuntimeError("Emulator tried to read outside vfs ('%s' not in '%s')." % (file_path, self._root_path))

return file_path

Expand Down