Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Writing file on resource directory or getting files from Document, Temporary directories — Gideros Forum

Writing file on resource directory or getting files from Document, Temporary directories

emreemre Member
edited July 2013 in General questions
On Gideros documentation it is stated that:
"Resource directory is read-only and you should not try to write any files there."

I try to create game data files (.json) by using Gideros, It contains point positions, etc.
Is there a way to obtain created files from 'document' or 'temporary' directories? (I will copy that files to resource folder)
Or is there a way to write file on resource directory.

Thanks

Comments

  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    @emre you can create and manage file inside Gideros application (which I think is the best practice), thus it would always be handled in the documents directory.

    Of course you can add it as resource with the project and copy it to the documents directory like that:
    local function copy(src, dst)
    	local srcf = io.open(src, "rb")
    	local dstf = io.open(dst, "wb")
    	local size = 2^13      -- good buffer size (8K)
    	while true do
    		local block = srcf:read(size)
    		if not block then break end
    		dstf:write(block)
    	end
    	srcf:close()
    	dstf:close()
    end
    local function exists(file)
    	local f = io.open(file, "rb")
    	if f == nil then
    		return false
    	end
    	f:close()
    	return true
    end
    if not exists("|D|file.txt") then
    	copy("file.txt", "|D|file.txt")
    end
    but I don't really see a point in doing so, having copy of information

    or if you want to view, what is in your documents directory, on PC or Mac that can be done easily:
    on Windows XP: C:\Documents and Settings\[YOUR USER NAME]\Local Settings\Temp\gideros\[YOUR APP NAME]
    on Windows Vista and Windows 7: C:\Users\[YOUR USER NAME]\AppData\Local\Temp\gideros\[YOUR APP NAME]
    on Mac OS X: $TMPDIR/gideros/[YOUR APP NAME]
  • emreemre Member
    Thanks ar2rsawseen, That is:
    "C:\Users\[YOUR USER NAME]\AppData\Local\Temp\gideros\[YOUR APP NAME]"
    the thing I am searching.

    The idea is, I am try to create a project in which I will create game level files.

    Thanks a lot.

    Likes: ar2rsawseen

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