|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
ByTransient Expert Cheater Reputation: 5
Joined: 05 Sep 2020 Posts: 240
|
Posted: Sat Jul 03, 2021 12:14 pm Post subject: Query whether a file exists. |
|
|
Test if all file types exist in the path you know.
(For windows below codes are working)
Note: The current test code is an alternative to "LuaFileSystem" (lfs.).
Code: | function pathExist(pth,fl1)
local file=pth..fl1
local fl2 = os.rename(file, file)
if not fl2 then
print("File not found")
else
print("file available")
end
return fl2
end |
Use:
Code: | --Folder
pathExist([[C:\Users\YourUserName\OneDrive\]],"Pictures") |
Code: | --files
pathExist([[C:\Users\YourUserName\Desktop\]],"Sample.txt") |
-------------------------------- or check and reName:
Code: | function pathExist(pth,fl1,refl)
local file=pth.."\\"..fl1
local fl2 = os.rename(file, file)
if not fl2 then
print("File not found")
else
if refl=="" then
print("file available")
else
local file1=pth.."\\"..refl
local fl2 = os.rename(file, file1)
print("New File name: "..refl.." success!")
end
end
return fl2
end |
--Use check name:
Code: | local cedir=getCheatEngineDir()
--or [[C:\Program Files\Cheat Engine 7.2]]
pathExist(cedir,"lua53-32.dll","") |
--Use rename:
Code: | pathExist([[C:\Users\YourUserName\Desktop]],"lost1.txt","lost2.txt") |
Enjoy it!
|
|
Back to top |
|
|
maskelihileci Cheater Reputation: 0
Joined: 08 Oct 2016 Posts: 43
|
Posted: Thu Feb 24, 2022 7:03 pm Post subject: |
|
|
Can we get the file version?
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 31
Joined: 16 Feb 2017 Posts: 1234
|
Posted: Fri Feb 25, 2022 2:05 am Post subject: |
|
|
maskelihileci wrote: | Can we get the file version? |
Code: | function pathExist(fl1,refl)
local fl2 = os.rename(fl1, fl1)
local fl3 = os.rename(refl, refl)
if not fl2 then return print(fl1 .. " not found")
elseif not fl3 then return print(refl .. " not found")
else
vrs1=fl1:match("[^\\]*$")
vrs2=refl:match("[^\\]*$")
if tonumber(vrs1:match("(%d+%p*%d+)")) < tonumber(vrs2:match("(%d+%p*%d+)")) then
print("File: '"..vrs2.."' Newer!")
return vrs2
else
print("File: '"..vrs1.."' Newer!")
return vrs1
end
end
end
local pth=[[C:\Users\YourUserName\Desktop]] --edit YourUserName
rst1=pathExist(pth .. "\\CT_V14.122.txt",pth .. "\\CT_V14.132.txt")
print(rst1)
-->rst1
--File: 'CT_V14.132.txt' Newer! |
_________________
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|