Skip to content

Commit f0c0885

Browse files
committed
Upload file
1 parent 0804d62 commit f0c0885

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

pio/src/main/assets/module/termux/py/contextpatch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"bin/logcat": "u:object_r:logcat_exec:s0",
1616
"system/bin": "u:object_r:system_file:s0",
1717
"/system/bin/init": "u:object_r:init_exec:s0",
18-
r"/lost\+found": "u:object_r:rootfs:s0"
18+
"/vendor/bin/hw/android.hardware.wifi@1.0": "u:object_r:hal_wifi_default_exec:s0"
1919
}
2020

2121

@@ -37,7 +37,7 @@ def scan_context(file) -> dict:
3737

3838
def scan_dir(folder) -> list:
3939
part_name = os.path.basename(folder)
40-
allfiles = ['/', '/lost+found', f'/{part_name}/lost+found', f'/{part_name}', f'/{part_name}/']
40+
allfiles = ['/', f'/{part_name}/lost+found', f'/{part_name}', f'/{part_name}/']
4141
for root, dirs, files in os.walk(folder, topdown=True):
4242
for dir_ in dirs:
4343
if os.name == 'nt':
@@ -52,7 +52,7 @@ def scan_dir(folder) -> list:
5252
return sorted(set(allfiles), key=allfiles.index)
5353

5454

55-
def context_patch(fs_file, filename) -> dict: # Receive two dictionaries for comparison
55+
def context_patch(fs_file, filename) -> dict:
5656
new_fs = {}
5757
permission_d = fs_file.get(list(fs_file)[0])
5858
if not permission_d:

pio/src/main/assets/module/termux/py/fspatch.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,20 @@ def scanfs(file) -> dict:
2020
print(f"[Warn] Current {line_num}: {filepath} there are too many schools ({len(other)}).")
2121
return filesystem_config
2222

23-
def scan_dir(folder) -> list:
24-
allfiles = ['/', '/lost+found']
25-
if os.name == 'nt':
26-
yield os.path.basename(folder).replace('\\', '')
27-
elif os.name == 'posix':
28-
yield os.path.basename(folder).replace('/', '')
29-
else:
30-
return ''
31-
for root, dirs, files in os.walk(folder, topdown=True):
32-
for dir_ in dirs:
33-
yield os.path.join(root, dir_).replace(folder, os.path.basename(folder)).replace('\\', '/')
34-
for file in files:
35-
yield os.path.join(root, file).replace(folder, os.path.basename(folder)).replace('\\', '/')
36-
for rv in allfiles:
37-
yield rv
38-
23+
def scan_dir(folder):
24+
base = os.path.basename(os.path.normpath(folder))
25+
yield base
26+
yield '/'
27+
yield f'{base}/lost+found'
28+
for root, dirs, files in os.walk(folder):
29+
rel_root = os.path.relpath(root, folder)
30+
rel_root = '' if rel_root == '.' else rel_root
31+
for d in dirs:
32+
path = os.path.join(base, rel_root, d)
33+
yield path.replace('\\', '/')
34+
for f in files:
35+
path = os.path.join(base, rel_root, f)
36+
yield path.replace('\\', '/')
3937

4038
def islink(file) -> str and None:
4139
if os.name == 'nt':

0 commit comments

Comments
 (0)