aboutsummaryrefslogtreecommitdiffstats
path: root/pySim
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2023-12-13 12:12:32 +0100
committerPhilipp Maier <pmaier@sysmocom.de>2023-12-13 12:45:46 +0100
commit14bf003dadef313635599dfb98edf8295d7f6237 (patch)
tree31248ad0579e5b764af16863c82863d657c662ce /pySim
parent174fd32f17b7147724933cc3d8e33ebbb9541831 (diff)
filesystem: use sort path when selecting an application
The method build_select_path_to uses the internal file system tree model to find the path to a given file. This works the same for applications (ADF) as it works for normal files (EF/DF). However, an application can be selected anytime from any location in the filesystem tree. There is no need to select a specific path leading to that application first. This means that if there is an ADF somewhere in the resulting inter_path, we may clip everything before that ADF. Related: OS#5418 Change-Id: I838a99bb47afc73b4274baecb04fff31abf7b2e2
Diffstat (limited to 'pySim')
-rw-r--r--pySim/filesystem.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index d39162c..35863a8 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -136,6 +136,16 @@ class CardFile:
return ret
def build_select_path_to(self, target: 'CardFile') -> Optional[List['CardFile']]:
+
+ # special-case handling for applications. Applications may be selected
+ # any time from any location. If there is an ADF somewhere in the path,
+ # we may clip everything before that ADF.
+ def clip_path(inter_path):
+ for i in reversed(range(0, len(inter_path))):
+ if isinstance(inter_path[i], CardADF):
+ return inter_path[i:]
+ return inter_path
+
"""Build the relative sequence of files we need to traverse to get from us to 'target'."""
# special-case handling for selecting MF while we MF is selected
if target == target.get_mf():
@@ -152,7 +162,7 @@ class CardFile:
for te2 in target_fqpath[i+1:]:
inter_path.append(te2)
# we found our common ancestor
- return inter_path[1:]
+ return clip_path(inter_path[1:])
return None
def get_mf(self) -> Optional['CardMF']: