get available memory on sd card - LUA Scripting - CHDK Forum  

get available memory on sd card

  • 4 Replies
  • 3235 Views
get available memory on sd card
« on: 21 / July / 2010, 15:28:24 »
Advertisements
Hi,

as the title says, is there a way to get the available free memory on the sd card in use?
Using Lua.
SX200

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: get available memory on sd card
« Reply #1 on: 21 / July / 2010, 16:58:04 »
Yes, get_free_disk_space() returns free disk space in kiB. I'm not 100% certain, but it will probably return an incorrect number if you have more than 4 GiB free.

Re: get available memory on sd card
« Reply #2 on: 21 / July / 2010, 17:36:48 »
Thanks,

Code: [Select]
print(get_free_disk_space() / (1024 * 1024)); prints 14; that's must be ~14GB free space. :)
Is there some documentation that lists such functions?

Now I need some function to copy the last picture that was taken.
If it's possible.
« Last Edit: 21 / July / 2010, 17:42:27 by mwarning »
SX200

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: get available memory on sd card
« Reply #3 on: 22 / July / 2010, 06:43:34 »
http://chdk.wikia.com/wiki/UBASIC/TutorialScratchpad
http://chdk.wikia.com/wiki/CHDK_firmware_usage/MoreBest#New_uBASIC_and_LUA_Scripting_Commands.21
http://chdk.wikia.com/wiki/LUA/LUA_Reference
http://chdk.wikia.com/wiki/LUA#LUA_standard_libraries:_io.2C_os_and_string

If something isn't documented properly or at all, in the end it's the source that matters (hint: there's a FUNC() macro in the end of luascript.c for each command CHDK adds to Lua):

http://tools.assembla.com/chdk/browser/trunk/core/luascript.c


It's possible to copy files using Lua i/o functions. CHDK/SCRIPTS/TEST/llibtst.lua and http://chdk.setepontos.com/index.php/topic,3291.msg34010.html#msg34010 should get you started with that and if my memory serves the latter may also show you how to find the latest file.


Re: get available memory on sd card
« Reply #4 on: 22 / July / 2010, 07:43:32 »
Thanks a lot!  ::)
SX200

 

Related Topics