/[classpath]/classpath/java/io/File.java
ViewVC logotype

Diff of /classpath/java/io/File.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.32 by mkoch, Wed May 21 12:18:44 2003 UTC revision 1.33 by rupp, Sat Jul 19 12:36:31 2003 UTC
# Line 180  public class File implements Serializabl Line 180  public class File implements Serializabl
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)
# Line 963  public class File implements Serializabl Line 963  public class File implements Serializabl
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;

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26