Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
LFS ACCESS USER DOCUMENT FOLDER — Gideros Forum

LFS ACCESS USER DOCUMENT FOLDER

MoKaLuxMoKaLux Member
edited March 2020 in General questions
How are you all doing?
I have a question please. Is it possible to know the path of the user pictures folder?
for example: C:\Users\USERNAME\Pictures\
I would like to use the RenderTarget:save(filename,x,y,width,height) function.
Do you think lfs can do it?
Thank you very much for your help.
my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories

Comments

  • hgy29hgy29 Maintainer
    Accepted Answer
    https://wiki.giderosmobile.com/index.php/Application:get
    print(application:get("directory","pictures"))
  • that's very handy, thanks for pointing out.
    does one of these refer to the 'root' directory on an android phone? (where usually apps put their own folder to store public stuff related to the app)
  • hgy29hgy29 Maintainer
    They are only working on QT based exports I am afraid
  • thank you very much <3
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • would be nice to associate some of them with folders on android as well, if that's possible. or have separate names for android folders, e.g. to root, download, dcim, sdcard root.
  • for android you can do it via media plugin. I will post an example later on today.

    Dislikes: JuanZambrano

    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+0 / -1 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited March 2020
    using the gmedia plugin you can change the folder you want to save on android.
    You need to modify the java code (don't worry it's easy):
    1- go to gideros installation folder and gmedia plugin:
    C:\Program Files (x86)\Gideros\All Plugins\gmedia\bin\Android\src\com\giderosmobile\android\plugins\media

    2- open GMedia.java (notepad++) and go to line 141

    3- by default the path is: SDCARD/Pictures you can change it!

    4- FOLDER NAME: line 143, you can change "/GIDEROS" folder name to something else (your app name)

    5- FILE NAME: line 144, you can change "img_" + timeStamp + ".png" to something else

    6- SAVE THE JAVA FILE

    7- RE-EXPORT YOUR APP

    It's quick and dirty but it works. You have to do the change for each of your apps you want to save to android.
    https://wiki.giderosmobile.com/index.php/Mediamanager:postPicture
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • an example for the original question:
    function Tile:saveTile()
    	-- CURRENT DATE AND TIME
    	local myyear = os.date("*t").year
    	local mymonth = os.date("*t").month; if mymonth < 10 then mymonth = "0"..mymonth end
    	local myday = os.date("*t").day; if myday < 10 then myday = "0"..myday end
    	local myhour = os.date("*t").hour; if myhour < 10 then myhour = "0"..myhour end
    	local mymin = os.date("*t").min; if mymin < 10 then mymin = "0"..mymin end
    	local mysec = os.date("*t").sec; if mysec < 10 then mysec = "0"..mysec end
    	local mytime = myyear..mymonth..myday.."_"..myhour..mymin..mysec
    	-- save
    	if application:getDeviceInfo() == "Android" then
    		mediamanager:postPicture("|T|mytile"..g_tilesize..".png")
    	else
    		local lfs = require "lfs"
    		lfs.chdir(application:get("directory","download"))
    		local dir = lfs.currentdir().."\\"
    		self.mytilert:save(dir.."mytile"..g_tilesize.."_"..mytime..".png")
    	end
    end
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • rrraptorrrraptor Member
    edited March 2020
    @MoKaLux as a suggestion, add pcall() to prevent app from crushing if something went wrong. Something like that:
    local TestClass = Core.class(Sprite)
    function TestClass:init()
    	local gfx = Pixel.new(math.random(0xffffff),1,32,32)
    	gfx:setAnchorPoint(.5,.5)
    	self:addChild(gfx)
    end
    -- methodName (string): name of the method that will be safely called
    -- ... - arguments for that method
    function TestClass:tryCatch(methodName, ...)
    	local status, error = pcall(self[methodName], self, ...)
    	if not status  then 
    		print(error) -- error is a string
    		-- if you are using "error" function, you can do something like that:
    		-- error({code = 404, message = "Page not found"}) 
    		-- print(error.code, error.message) --> "404 Page not found"
    	end
    end
     
    function TestClass:doStuff()
    	for k,v in ipairs(nil) do end
    end
     
    local obj = TestClass.new()
    obj:setPosition(application:getLogicalWidth() / 2, application:getLogicalHeight() / 2)
    stage:addChild(obj)
     
    -- instead of calling "doStuff" method directly, use tryCatch method to safely call
    -- code that can possibly crush the app
    obj:tryCatch("doStuff") -- main.lua:17: bad argument #1 to 'ipairs' (table expected, got nil)
     
    -- just an animation to show that app is still runing
    local anim = MovieClip.new{
    	{1,60,obj, {scale = {1, 0.7, "outBack"}, rotation = {0, 90, "linear"}}}
    }
    anim:setGotoAction(60,1)

    Likes: MoKaLux

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