File attribute D_SECOND from dir() not correct?
- Posted by Alan Oxley <fizzpop at axemail.co.za> Dec 22, 2006
- 671 views
Hi everybody, I've started a CD cataloging program and noticed that the number of seconds returned via D_SECOND set by dir() seems to be 1 second different from the value displayed by Windows (2000, sp6) file properties. Here is code to demonstrate; anybody know why the 1 second issue?
-- -- scan cd 22/12/06 A Oxley -- -- Euphoria v2.5 licenced -- -- program invoked via "exw.exe" rather than "ex.exe" -- so that long filenames with case sensitivity is supported. include file.e -- default from euphoria\include include get.e -- default from euphoria\include -- with trace with type_check without profile with warning -- integer file_count file_count = 0 -- procedure storeit(sequence data) sequence s1, s2 integer i3, i4, i5, i6, i7, i8, i9 s1 = data[1] -- full filename s2 = data[2] -- attribs d r h s v a i3 = data[3] -- file size in bytes, not allocated size i4 = data[4] -- last save year i5 = data[5] -- month i6 = data[6] -- day i7 = data[7] -- hour i8 = data[8] -- min i9 = data[9] -- seconds D_SECOND in file.e if file_count = 24 then ?1/0 end if -- pick any file <=== end procedure function xwalk_dir(sequence path_name) -- walk through a directory and its subdirectories -- "looking" at each file -- modified version of RDS code "TOP.EX" in archive "goodies.zip" object d atom a1 sequence name, full_path, s1, mydir, mypath d = dir(path_name) while find(path_name[length(path_name)], " \\") do path_name = path_name[1..length(path_name)-1] end while if atom(d) then -- puts(1, "Couldn't open " & path_name & '\n') return file_count end if for i = 1 to length(d) do name = d[i][D_NAME] if not find(name, {".", ".."}) then full_path = path_name & '\\' & name if find('d', d[i][D_ATTRIBUTES]) then -- directory a1 = xwalk_dir(full_path) else -- file file_count = file_count + 1 -- another dir is done here as I prefer to -- grab this output instead of digging through -- unknown levels of directories. -- It seems to be a cache hit anyway. s1 = dir(full_path) mydir = s1[1] -- drop leading drive letter, colon and slash mypath = full_path[4..length(full_path)] mydir[1] = mypath storeit(mydir) end if end if end for return file_count end function procedure main() atom a1 sequence s1 a1 = xwalk_dir("E:\\") -- <=== change to your CD drive letter s1 = sprintf("%6d",{file_count}) puts(1," Total files found is " & s1 & "\n") a1 = wait_key() -- hold console open for display end procedure main()