commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject cvs commit: jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl DefaultFileReplicator.java
Date Mon, 17 May 2004 17:53:08 GMT
imario      2004/05/17 10:53:08

  Modified:    vfs/src/java/org/apache/commons/vfs/impl
                        DefaultFileReplicator.java
  Log:
  BUG29007: Allow overloading of
  filename-creation = createFilename()
  and
  file-creation = createFile()
  
  Revision  Changes    Path
  1.17      +29 -2     jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/DefaultFileReplicator.java
  
  Index: DefaultFileReplicator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/DefaultFileReplicator.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DefaultFileReplicator.java	10 May 2004 20:09:46 -0000	1.16
  +++ DefaultFileReplicator.java	17 May 2004 17:53:08 -0000	1.17
  @@ -43,6 +43,11 @@
       private File tempDir;
       private long filecount;
   
  +    /**
  +     * constructor to set the location of the temporary directory
  +     *
  +     * @param tempDir
  +     */
       public DefaultFileReplicator(final File tempDir)
       {
           this.tempDir = tempDir;
  @@ -61,6 +66,7 @@
           {
               tempDir = new File("vfs_cache").getAbsoluteFile();
           }
  +
           filecount = new Random().nextInt() & 0xffff;
       }
   
  @@ -99,14 +105,35 @@
       public File allocateFile(final String baseName)
       {
           // Create a unique-ish file name
  -        final String basename = baseName + "_" + filecount + ".tmp";
  +        final String basename = createFilename(baseName);
           filecount++;
  -        final File file = new File(tempDir, basename);
  +        final File file = createFile(tempDir, basename);
   
           // Keep track to delete later
           copies.add(file);
   
           return file;
  +    }
  +
  +    protected long getFilecount()
  +    {
  +        return filecount;
  +    }
  +
  +    /**
  +     * create the temporary file name
  +     */
  +    protected String createFilename(final String baseName)
  +    {
  +        return baseName + "_" + getFilecount() + ".tmp";
  +    }
  +
  +    /**
  +     * create the temporary file
  +     */
  +    protected File createFile(final File parent, final String name)
  +    {
  +        return new File(parent, name);
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message