73 lines
2.3 KiB
Python
73 lines
2.3 KiB
Python
#EFLC Shrinker by Fierelier.
|
|
#Feel free to do whatever with this.
|
|
|
|
version = "0.8a"
|
|
import sys
|
|
import os
|
|
import filecmp
|
|
|
|
def shrinkExcept(exc_type, exc_value, tb):
|
|
originalExcept(exc_type, exc_value, tb)
|
|
input("\nPress ENTER to exit.")
|
|
|
|
originalExcept = sys.excepthook
|
|
sys.excepthook = shrinkExcept
|
|
|
|
def clear():
|
|
os.system("cls")
|
|
|
|
def title(text):
|
|
os.system("title " +text)
|
|
|
|
def shrinkEFLC(ivPath,eflcPath,compMethod):
|
|
clear()
|
|
#Check if EFLC path is correct.
|
|
if not os.path.isfile(os.path.join(eflcPath,"LaunchEFLC.exe")): input("Error! EFLC path is incorrect.\nPress ENTER to continue."); return False
|
|
if os.path.isfile(os.path.join(ivPath,"LaunchEFLC.exe")): input("Error! IV path is incorrect.\nPress ENTER to continue."); return False
|
|
if not os.path.isfile(os.path.join(ivPath,"LaunchGTAIV.exe")): input("Error! IV path is incorrect.\nPress ENTER to continue."); return False
|
|
print("Shrinking EFLC...")
|
|
savings = 0.0
|
|
|
|
for root, dirs, files in os.walk(ivPath):
|
|
for file in files:
|
|
fullFile = os.path.join(root,file)
|
|
newFile = fullFile.replace(ivPath,eflcPath)
|
|
compactFile = fullFile.replace(ivPath,"")
|
|
if not os.path.isfile(newFile): continue
|
|
print("Comparing '" +compactFile+ "'...")
|
|
if compMethod == 1:
|
|
if os.path.getsize(fullFile) != os.path.getsize(newFile): continue
|
|
else:
|
|
if not filecmp.cmp(fullFile,newFile): continue
|
|
print("Files are identical, replacing.")
|
|
savings = savings + (os.path.getsize(fullFile)/1000000)
|
|
os.remove(newFile)
|
|
os.link(fullFile,newFile)
|
|
|
|
print("\nShrunk EFLC, you're saving " +str(round(savings))+ "MB")
|
|
return True
|
|
|
|
title("EFLC Shrinker " +version)
|
|
while True:
|
|
clear()
|
|
print("Just drag & drop your games' folders into this window and press ENTER")
|
|
print("WARNING! I am not responsible for any broken games.")
|
|
iv = input("GTA IV Path: ").replace('"','')
|
|
eflc = input("EFLC Path: ").replace('"','')
|
|
method = 0
|
|
while True:
|
|
clear()
|
|
print("\nChoose a comparison method:\n1) Slow & Secure (Recommended)\n2) Quick & Dirty")
|
|
method = input()
|
|
try:
|
|
method = int(method)
|
|
except:
|
|
continue
|
|
|
|
if (method != 1 and method != 2): continue
|
|
method = method - 1
|
|
break
|
|
|
|
success = shrinkEFLC(iv,eflc,method)
|
|
if success == True: input("Press ENTER to quit."); break
|
|
if success == False: input("Press ENTER to try again.") |