[tcljava-dev] Jacl and file mtime
Brought to you by:
mdejong
From: <cs...@ma...> - 2001-01-08 07:02:27
|
Hi! I am using the Java implementation of Tcl, called Jacl, version 1.2.6. I just tried to use the "file mtime <filename>" command and found out that it does not work properly (on Windows 95/NT, that is). The reason seems to be that the Tcl concept of integers is 32-bit and that the Java File.getModified() method returns a long too long to be stored in an int. By experimenting with File.getModified() in pure Java (on Windows 95) I found out that the three rigtmost digits of this huge number always were "000". So, by fixing tcl.lang.FileCmd's method getMtime() to return the time / 1000, "file mtime" became acceptable for an int - and it became useful, e.g. for "make" like utilities. Recap: In tcl.lang.FileCmd, method getMtime(), I changed: return (int) fileObj.lastModified(); to something like: long l = fileObj.lastModified(); return (int) (l / 1000); I should stress that I this was tested on Windows 95, where I get that long (12 decimal digits) result but always with "000" in the rightmost three digits. On Windows NT 4, I get a similarly long number but actually the three rightmost digits are not (always) "000". But maybe the granularity is so fine here that my simple fix still would work for all practical purposes. From Windows NT, I have two files with the same timestamp (<hours>:<minutes>), i.e. same minute, and they are different from the 5'th digit from the right, not bad: 978591035662 978591042491 By the way: This "97" indicates that soon (?) we should be able to handle 13 digits!!? What happens on non-Windows platforms I don't know. I considered introducing the Java type "long" in Jacl but that seems hard to control and a violation of some nice and simple principles for Tcl per se. Kind regards, Christian Sorensen. |