/[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.49.2.6 by tromey, Tue Sep 27 16:59:22 2005 UTC revision 1.49.2.7 by gnu_andrew, Wed Nov 2 00:43:32 2005 UTC
# Line 100  public class File implements Serializabl Line 100  public class File implements Serializabl
100     * may be an absolute or relative path name.     * may be an absolute or relative path name.
101     */     */
102    private String path;    private String path;
103      
104      
105      /**
106       * The time (millisecond), when the last temporary file was created.
107       */
108      private static long last_tmp;
109      
110      /**
111       * The number of files, created during the current millisecond.
112       */
113      private static int n_created;  
114    
115    /**    /**
116     * This method tests whether or not the current thread is allowed to     * This method tests whether or not the current thread is allowed to
# Line 1059  public class File implements Serializabl Line 1070  public class File implements Serializabl
1070     *     *
1071     * @since 1.2     * @since 1.2
1072     */     */
1073    public static File createTempFile(String prefix, String suffix,    public static synchronized File createTempFile(String prefix, String suffix,
1074                                      File directory)                                      File directory)
1075      throws IOException      throws IOException
1076    {    {
# Line 1091  public class File implements Serializabl Line 1102  public class File implements Serializabl
1102      // Now identify a file name and make sure it doesn't exist.      // Now identify a file name and make sure it doesn't exist.
1103      File file;      File file;
1104      if (!VMFile.IS_DOS_8_3)      if (!VMFile.IS_DOS_8_3)
1105        {              {
1106          do          do
1107            {            {
1108              String filename = prefix + System.currentTimeMillis() + suffix;              long now = System.currentTimeMillis();
1109                if (now > last_tmp)
1110                  {
1111                    // The last temporary file was created more than 1 ms ago.
1112                    last_tmp = now;
1113                    n_created = 0;
1114                  }
1115                else
1116                  n_created++;
1117                
1118                String name = Long.toHexString(now);
1119                if (n_created > 0)
1120                  name += '_'+Integer.toHexString(n_created);
1121                String filename = prefix + name + suffix;
1122              file = new File(directory, filename);              file = new File(directory, filename);
1123            }            }
1124          while (VMFile.exists(file.path));          while (VMFile.exists(file.path));

Legend:
Removed from v.1.49.2.6  
changed lines
  Added in v.1.49.2.7

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