Check out example codes for "how to check if file exists lua". It will help you in understanding the concepts better.

Code Example 1

function file_exists(name)
   local f=io.open(name,"r")
   if f~=nil then io.close(f) return true else return false end
end

Learn ReactJs, React Native from akashmittal.com