Andrew Haley wrote: > Gary Benson writes: > > I just noticed that File.canWrite() actually writes things in > > order to check whether they are writable. This seems really wrong > > to me: just checking something should not modify the filesystem! > > Does anyone mind if I replace this? > > I agree with you. We should just use access("file", W_OK). > > The gcj source I'm looking at has > > public boolean canWrite() > { > checkWrite(); > return _access (WRITE); > } > > which is correct, but the Classpath native code I'm looking at uses > > /* The lazy man's way out. We actually do open the file for writing > briefly to verify it can be done */ > TARGET_NATIVE_FILE_OPEN_READWRITE (filename, fd, result); > (*env)->ReleaseStringUTFChars (env, name, filename); > if (result != TARGET_NATIVE_OK) > { > return (0); > } > TARGET_NATIVE_FILE_CLOSE (fd, result); > > I can't see any code that actually writes anything. That particular bit doesn't write any bytes, but it modifies the file's timestamp. If you look in VMFile.canWriteDirectory() you'll see some actual writing. Cheers, Gary