RevealedSoulEven Posted April 16, 2021 Share Posted April 16, 2021 I'm creating a password session that is automatically saved in the internal storage. So that the users don't have to put it again. Once it's created I can check the password. I did that. But the thing is if the file doesn't existed there then how to verify? If the file is present in the storage or not? Link to comment Share on other sites More sharing options...
CmP Posted April 16, 2021 Share Posted April 16, 2021 function file_exists(name) local f=io.open(name,"r") if f~=nil then io.close(f) return true else return false end end Source: https://stackoverflow.com/a/499160 Link to comment Share on other sites More sharing options...
RevealedSoulEven Posted April 16, 2021 Author Share Posted April 16, 2021 Just now, CmP said: function file_exists(name) local f=io.open(name,"r") if f~=nil then io.close(f) return true else return false end end Source: https://stackoverflow.com/a/499160 Thank you for your help sir... But I've already saw that on stackoverflow and it's not working with GG. Because it doesn't return nil instead it returns something else. Randomly so.. we can't Link to comment Share on other sites More sharing options...
CmP Posted April 16, 2021 Share Posted April 16, 2021 1 minute ago, RevealedSoulEven said: Because it doesn't return nil instead it returns something else. Randomly so.. we can't Provide an example of what "io.open" function returns for existing file and non-existing one. You can use the following code for this: local path = "/path/to/a/file" print(io.open(path, "r")) Link to comment Share on other sites More sharing options...
RevealedSoulEven Posted April 16, 2021 Author Share Posted April 16, 2021 2 minutes ago, CmP said: Provide an example of what "io.open" function returns for existing file and non-existing one. You can use the following code for this: local path = "/path/to/a/file" print(io.open(path, "r")) Thank you sir I'll try [added 2 minutes later] 4 minutes ago, CmP said: Provide an example of what "io.open" function returns for existing file and non-existing one. You can use the following code for this: local path = "/path/to/a/file" print(io.open(path, "r")) Yes sir that's working. Thank you Link to comment Share on other sites More sharing options...
Question
RevealedSoulEven
I'm creating a password session that is automatically saved in the internal storage. So that the users don't have to put it again.
Once it's created I can check the password. I did that.
But the thing is if the file doesn't existed there then how to verify? If the file is present in the storage or not?
Link to comment
Share on other sites
4 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.