preliminary lua iolib and oslib port - page 3 - General Discussion and Assistance - CHDK Forum
supplierdeeply

preliminary lua iolib and oslib port

  • 36 Replies
  • 22707 Views
Re: preliminary lua iolib and oslib port
« Reply #20 on: 25 / September / 2008, 14:19:31 »
Advertisements
Here is the patch for the os.tmpname. Please review and if any changes are required do tell me I will.  :)


Re: preliminary lua iolib and oslib port
« Reply #21 on: 27 / September / 2008, 16:31:10 »
Here is the updated patch os.tmpname() for lua. And I had tested it using a small script(a 3 line script).
This patch has been tested in my camera A720IS.


*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: preliminary lua iolib and oslib port
« Reply #22 on: 30 / September / 2008, 11:55:01 »
tested the patch and the script you supplied, seems to work. the tmp dir got created. then the script created files. then after reboot, the tmp dir was empty. i guess it would be better to not delete the stuff in tmp, as people may move stuff into that (in windows for example), not knowing that it got created by chdk and especially not knowing that all things in there got deleted, no?

Re: preliminary lua iolib and oslib port
« Reply #23 on: 30 / September / 2008, 16:10:46 »
I am submitting the latest patch with the changes I had made as per reyalp's request. Now I am using only 2 sprintfs's to create the file. And a special check is made for already deleted entry. The test code for checking this functionality remains the same. The old test.lua. I am adding that too.


*

Offline reyalp

  • ******
  • 14080
Re: preliminary lua iolib and oslib port
« Reply #24 on: 23 / October / 2008, 21:42:19 »
Added os.stat and os.utime (both not in the standard lua os library, but they fit logically there)
These work roughly the same way as the C functions of the same names.

stat takes a file name, and returns a table on success, or nil plus an error message and errno.
The table has the following fields (all numbers)
 dev: device number
 mode: not clear which bits are useful. it does change depending on whether you look at a file or directory (but you should use attrib or is_* below instead)
 size: size in bytes
 atime: time of last access
 mtime: time of last modification
 ctime: time of last change of file status
 blksize: block size in bytes. This is NOT the dos sector size. 512 on all I've tested, possibly hardware block size.
 blocks: Number of blksize blocks in the file. blocks*blocksizes is not the same as "size on disk", per above.
 attrib: bitmask of dos attributes (see stdlib.h)
The following boolean values are set based on attrib, so you don't have to do bit testing for the most common values of interest:
 is_dir
 is_file
Note that it is possible for to stat things that are neither file nor directory, e.g. volume labels. So you should test for exactly what you want, rather than assuming that NOT is_file is a directory.

Note that for files larger than 2gb would appear to have a negative size in lua.

utime takes a file name, followed by optional numbers for mtime and atime (describe above). If either time is missing, the current time is used. It returns true on success, or nil, "error message", errno.

llibtst.lua is updated to test these functions, and is now included in the distribution directory CHDK/SCRIPTS/TEST/LLIBTST.LUA

I haven't added sujithh's tmpname. The effort is appreciated, but IMO it's probably better to do the whole thing in lua. I apologize for any wasted time.
Don't forget what the H stands for.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: preliminary lua iolib and oslib port
« Reply #25 on: 26 / October / 2008, 10:51:09 »
Appears to work fine on a570is 1.00e, including the new additions. Great progress reyalp!

*

Offline fe50

  • ******
  • 3147
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: preliminary lua iolib and oslib port
« Reply #26 on: 28 / October / 2008, 08:56:56 »
Successfully tested also on SD400 1.01B with #545 build.

*

Offline reyalp

  • ******
  • 14080
Re: preliminary lua iolib and oslib port
« Reply #27 on: 10 / November / 2008, 02:47:53 »
I've added directory listing: changelog of trunk including comments / devtalk
If someone can make sure it works under dryos, that would be appreciated.
Don't forget what the H stands for.


*

Offline fe50

  • ******
  • 3147
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: preliminary lua iolib and oslib port
« Reply #28 on: 10 / November / 2008, 04:58:43 »
I've added directory listing: changelog of trunk including comments / devtalk
If someone can make sure it works under dryos, that would be appreciated.

Tested full ok with SD400 1.01b (VxWorks)  (#555 with included llibtst.lua)

With the SD870 1.00c (DryOS) i got 1 issue: os.listdir("A/llibtst.log",nil): OK FAIL

(logs attached)

*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: preliminary lua iolib and oslib port
« Reply #29 on: 10 / November / 2008, 05:59:58 »
Great work!

The same result for the A720 as a dryos cam - see attach.

Your script is to much for my skill.  :D I try little script for me:
Code: (lua) [Select]
--[[
@title list dir
]]

showall = true

dir = os.listdir("A/CHDK", showall)

count = table.getn(dir)
x = 0
for i=1, count do
print(i..".",dir[i])
x = x + 1
if x == 4 then
wait_click(0)
x = 0
end
end
sleep(3000)
wait_click(0)

It works, but it will no show "." or "..".

msl



« Last Edit: 11 / November / 2008, 06:46:58 by msl »
CHDK-DE:  CHDK-DE links

 

Related Topics