Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How to delete a file from Document directory? — Gideros Forum

How to delete a file from Document directory?

anskurtanskurt Member
edited December 2013 in General questions
I am making a level editor and the levels are stored in the Document directory. I want to be able to delete levels by pressing a button in the app. Right now i just erase all the data in the file by writing over it with an empty string, but is there a way to remove the file completely?

Comments

  • ar2rsawseenar2rsawseen Maintainer
    edited December 2013 Accepted Answer
    Hello @anskurt
    You can try:
    os.remove("|D|filename")

    Likes: anskurt

    +1 -1 (+1 / -0 )Share on Facebook
  • Thanks for another quick answer.
    Should have found that myself since it was in the documentation. :)
  • what if i want to delete all files in the documen directory ? i cant find function that at least tells me list of all files in a folder in the gideros reference manual
  • @bysreg
    you can use Lua File System plugin:
    require "lfs"
     
    function listdir (path)
    	for file in lfs.dir(path) do
    		if file ~= "." and file ~= ".." then
    			local f = path..'/'..file
    			print (f)
    		end
    	end
    end
     
    listdir (".")
  • @ar2rsawseen
    Thank you very much. I didnt notice this. the gideros manual on lfs is still empty(so i thought it was still unsupported)

    Likes: chipster123

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.