caching of lastmodified, was: [jcifs] Equivalent for java.io.File.getCanonicalPath()

Julian Reschke julian.reschke at gmx.de
Tue Feb 3 15:01:14 GMT 2004


OK, here's a testcase for:

> ...
> 1) Caching of lastmodified(): after new SmbFile(), new 
> SmbFileOutputStream(), .close, lastmodified() on the SmbFile still 
> returns 0.
 > ...

	private static boolean testSetLastMod() throws IOException {
		
		SmbFile smb = new SmbFile("smb://" + creds + host + "/" + share + 
"/newfile2");
		System.out.println(smb.getCanonicalPath());
		
		SmbFileOutputStream so = new SmbFileOutputStream(smb);
		so.close();
		
		smb.setLastModified(60L * 60L * 24L * 365L * 1000L);
		
		System.out.println("lastmod before write: " + smb.lastModified());
		
		so = new SmbFileOutputStream(smb);
		so.write("Hello".getBytes());
		so.close();

		System.out.println("lastmod after write: " + smb.lastModified());

		smb = new SmbFile("smb://" + creds + host + "/" + share + "/newfile2");
		System.out.println("lastmod after getting new smbfile: " + 
smb.lastModified());
		
		return smb.exists();
	}

yields:

lastmod before write: 31536000000
lastmod after write: 31536000000
lastmod after getting new smbfile: 1075820346592

So the lastmod timestamp on a given SmbFile object doesn't get updated 
when the file was written to using an SmbFileOutputStream.

Regards, Julian


-- 
<green/>bytes GmbH -- http://www.greenbytes.de -- tel:+492512807760


More information about the jcifs mailing list