[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [StrongED] Time stamps
In message <e92c0ae656.fjgraute@xxxxxxxxx>
Fred Graute <fjgraute@xxxxxxxxx> wrote:
> I've done something similar (in Lua) to update my local copy of the
> StrongED website. As far as I can see it's working fine. How are you
> comparing the time stamps?
I am using RO 5.23 on a Raspberry Pi3. So 'disk' is an SD card.
My timestamp-compare code is slightly Byzantine. Function ok
should return true if either fout (the target) does not exist or if its
time stamp is earlier than that of fin (the source):
local funny = " has a funny type"
local ok = \ (fin, fout)
local r0,r1,r2,r3 = sys (8,23,fout..'\0') -- OS_File
if r0 == 0 then => true end -- if (fout non-existent)
assert (r0 == 1, fout..funny)
local s0,s1,s2,s3 = sys (8,23, fin..'\0')
assert (s0 == 1, fin..funny)
r3 & = 0xff
s3 & = 0xff
if s3 > r3 then => true end -- if (5-th byte compared)
if s3 < r3 then => end -- if
local r2h = (r2 & 0xff000000) >> 6
local s2h = (s2 & 0xff000000) >> 6
if s2h > r2h then => true end -- if (4-th byte compared)
if s2h < r2h then => end -- if
r2 & = 0x00ffffff
s2 & = 0x00ffffff
=> (s2 > r2) -- (bottom three bytes compared)
end -- function
It is probably not optimal, and I may be being excessively cautious
about avoiding signed comparisons.
--
Gavin Wraith (gavin@xxxxxxxxxxxxxxx)
Home page: http://www.wra1th.plus.com/
--
To unsubscribe send a mail to StrongED+unsubscribe@xxxxxxxxxxx
List archives and instructions at
http://diy.Torrens.org/RO/StrongED/index.html