180 |
else |
else |
181 |
try |
try |
182 |
{ |
{ |
183 |
File test = createTempFile ("test-dir-write", null, this); |
File test = createTempFile ("tst", null, this); |
184 |
return (test != null && test.delete ()); |
return (test != null && test.delete ()); |
185 |
} |
} |
186 |
catch (IOException ioe) |
catch (IOException ioe) |
963 |
|
|
964 |
// Now process the prefix and suffix. |
// Now process the prefix and suffix. |
965 |
if (prefix.length () < 3) |
if (prefix.length () < 3) |
966 |
throw new IllegalArgumentException ("Prefix too short: " + prefix); |
throw new IllegalArgumentException ("Prefix too short: " + prefix + "(valid length 3..7)"); |
967 |
|
if (prefix.length() >= 8) |
968 |
|
throw new IllegalArgumentException("Prefix too long: " + prefix + "(valid length 3..7)"); |
969 |
|
|
970 |
if (suffix == null) |
if (suffix == null) |
971 |
suffix = ".tmp"; |
suffix = ".tmp"; |
972 |
|
|
973 |
// Now identify a file name and make sure it doesn't exist |
// Now identify a file name and make sure it doesn't exist (limit the name to 8 for DOS-compatibility) |
974 |
File f; |
File f; |
975 |
|
int mask = (int)(0x000000ffffFFFFL >> (long)(prefix.length() * 4)); |
976 |
for(;;) |
for(;;) |
977 |
{ |
{ |
978 |
String filename = prefix + System.currentTimeMillis () + suffix; |
int n = (int)(System.currentTimeMillis() & mask); |
979 |
f = new File (directory, filename); |
String filename = prefix + java.lang.Integer.toHexString(n) + suffix; |
980 |
|
f = new File(directory, filename); |
981 |
|
|
982 |
if (f.exists ()) |
if (f.exists()) |
983 |
continue; |
continue; |
984 |
else |
else |
985 |
break; |
break; |