Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug of vfs on macos #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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