forked from Lost-Ark-Market-Online/LostArk-Market-Watcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_find.py
37 lines (27 loc) · 845 Bytes
/
test_find.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import string
import os
import re
from ctypes import windll
def get_drives():
drives = []
bitmask = windll.kernel32.GetLogicalDrives()
for letter in string.ascii_uppercase:
if bitmask & 1:
drives.append(f"{letter}:\\")
bitmask >>= 1
return drives
print(get_drives())
def find_file(root_folder, rex):
for root, _, files in os.walk(root_folder):
for f in files:
result = rex.search(f)
if result:
return os.path.join(root, f)
def find_file_in_all_drives(file_name):
rex = re.compile(file_name)
for drive in get_drives():
return find_file(drive, rex)
lostark_file = find_file_in_all_drives('LOSTARK\.exe')
lostark_directoy = os.path.abspath(os.path.join(
os.path.dirname(lostark_file), '..', '..'))
print(lostark_directoy)