Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Query whether a file exists.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials
View previous topic :: View next topic  
Author Message
ByTransient
Expert Cheater
Reputation: 1

Joined: 05 Sep 2020
Posts: 191

PostPosted: Sat Jul 03, 2021 12:14 pm    Post subject: Query whether a file exists. Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites