You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Torsten Curdt <tc...@apache.org> on 2005/08/12 13:31:43 UTC
last modified
Guys,
I hope this is not too OT for this list but I
am running out of ideas. What could be possibly
be wrong with the following piece of code:
import java.io.File;
public class test {
public static void main(String[] args) throws Exception {
File dir = new File("dir");
dir.mkdir();
long m = dir.lastModified();
File subdir = new File(dir, "subdir");
subdir.mkdir();
while(dir.lastModified() == m) {
Thread.sleep(1000);
System.out.print('.');
}
subdir.delete();
dir.delete();
}
}
To me it seems like the last modified
is not being updated (even if I re-create
the File object) unless the directory
gets touched *outside* the jvm.
Anyone aware of this problem?
cheers
--
Torsten
Re: last modified
Posted by Torsten Curdt <tc...@apache.org>.
> This might have to do something with the timestamp resolution of
> the filesystem. Not every filesystem have a resolution of
> milliseconds but some higher factor.
Yeah, Brett already pointed offlist me on that.
> It gets ever worse e.g 10ms for FAT on create but 2sec for write
> (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/
> fileio/fs/setting_and_getting_the_timestamp_of_a_file.asp)
> To be cross platform dont expect more than 2sec.
>
> Bad news, isnt it?
Ouch! Hmm... need to think about
what implications this might have
for the jci monitor...
> Mario
>
> PS: After some googling I found it might be worth to collect those
> precision and create a web page with them.
Sounds like a good idea
Thanks
--
Torsten
Re: last modified
Posted by Stefan Bodewig <bo...@apache.org>.
On Fri, 12 Aug 2005, Mario Ivankovits <ma...@ops.co.at> wrote:
> To be cross platform dont expect more than 2sec.
Ant uses 2 secs on windows and 1 sec on Unix as a heuristic. It is
not correct (it depends on the filesystem, not the OS[1]) but a good
guess in most cases.
Stefan
Footnotes:
[1] NTFS could be better than 2 secs, while a FAT fs mounted via
SMB on Linux would need 2 for example.
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
For additional commands, e-mail: general-help@jakarta.apache.org
Re: last modified
Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi Torsten!
> public static void main(String[] args) throws Exception {
> File dir = new File("dir");
> dir.mkdir();
> long m = dir.lastModified();
> File subdir = new File(dir, "subdir");
This might have to do something with the timestamp resolution of the
filesystem. Not every filesystem have a resolution of milliseconds but
some higher factor.
It gets ever worse e.g 10ms for FAT on create but 2sec for write
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/setting_and_getting_the_timestamp_of_a_file.asp)
To be cross platform dont expect more than 2sec.
Bad news, isnt it?
---
Mario
PS: After some googling I found it might be worth to collect those
precision and create a web page with them.
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
For additional commands, e-mail: general-help@jakarta.apache.org
Re: last modified
Posted by Henning Schmiedehausen <hp...@intermeta.de>.
What filesystem, what OS?
Linux with ext2/ext3 has 1 second timestamp granularity.
Linux 2.6 claims to have nanosecond resolution on some filesystems (e.g.
XFS, JFS). See
http://www.uwsg.iu.edu/hypermail/linux/kernel/0210.3/0793.html
On Linux I wouldn't rely on anything below 1 second resolution though.
Stefans' heuristics are probably a good thing.
There are a number of discussions on LKML because of nanosecond
truncating on some file systems in relation to make-driven builds. This
probably hurts ant, too:
http://www.ussg.iu.edu/hypermail/linux/kernel/0404.0/0193.html
Regards
Henning
On Fri, 2005-08-12 at 13:31 +0200, Torsten Curdt wrote:
> Guys,
>
> I hope this is not too OT for this list but I
> am running out of ideas. What could be possibly
> be wrong with the following piece of code:
>
> import java.io.File;
>
> public class test {
> public static void main(String[] args) throws Exception {
> File dir = new File("dir");
> dir.mkdir();
> long m = dir.lastModified();
> File subdir = new File(dir, "subdir");
> subdir.mkdir();
> while(dir.lastModified() == m) {
> Thread.sleep(1000);
> System.out.print('.');
> }
> subdir.delete();
> dir.delete();
> }
> }
>
> To me it seems like the last modified
> is not being updated (even if I re-create
> the File object) unless the directory
> gets touched *outside* the jvm.
>
> Anyone aware of this problem?
>
> cheers
> --
> Torsten
--
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
hps@intermeta.de +49 9131 50 654 0 http://www.intermeta.de/
RedHat Certified Engineer -- Jakarta Turbine Development
Linux, Java, perl, Solaris -- Consulting, Training, Engineering
4 - 8 - 15 - 16 - 23 - 42
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
For additional commands, e-mail: general-help@jakarta.apache.org