-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
42 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,37 @@ | ||
import string | ||
import os | ||
import re | ||
import win32api | ||
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 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 win32api.GetLogicalDriveStrings().split('\000')[:-1]: | ||
return find_file( drive, rex ) | ||
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) | ||
lostark_directoy = os.path.abspath(os.path.join( | ||
os.path.dirname(lostark_file), '..', '..')) | ||
print(lostark_directoy) |