Browse Source

File.getParentFile is availablae in JDK1.2+ !

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270244 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 24 years ago
parent
commit
b88df41411
10 changed files with 14 additions and 56 deletions
  1. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Available.java
  2. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Expand.java
  3. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Replace.java
  4. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java
  5. +2
    -23
      proposal/myrmidon/src/main/org/apache/tools/ant/util/FileUtils.java
  6. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Available.java
  7. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Expand.java
  8. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Replace.java
  9. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Zip.java
  10. +2
    -23
      proposal/myrmidon/src/todo/org/apache/tools/ant/util/FileUtils.java

+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Available.java View File

@@ -275,7 +275,7 @@ public class Available
} }


FileUtils fileUtils = FileUtils.newFileUtils(); FileUtils fileUtils = FileUtils.newFileUtils();
File parent = fileUtils.getParentFile( path );
File parent = path.getParentFile();
// ** full-pathname specified == parent dir of path in list // ** full-pathname specified == parent dir of path in list
if( parent != null && parent.exists() if( parent != null && parent.exists()
&& file.equals( parent.getAbsolutePath() ) ) && file.equals( parent.getAbsolutePath() ) )
@@ -317,7 +317,7 @@ public class Available
// ** simple name specified == parent of parent dir + name // ** simple name specified == parent of parent dir + name
if( parent != null ) if( parent != null )
{ {
File grandParent = fileUtils.getParentFile( parent );
File grandParent = parent.getParentFile();
if( grandParent != null && grandParent.exists() ) if( grandParent != null && grandParent.exists() )
{ {
if( checkFile( new File( grandParent, file ), if( checkFile( new File( grandParent, file ),


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Expand.java View File

@@ -251,7 +251,7 @@ public class Expand extends MatchingTask
log( "expanding " + entryName + " to " + f, log( "expanding " + entryName + " to " + f,
Project.MSG_VERBOSE ); Project.MSG_VERBOSE );
// create intermediary directories - sometimes zip don't add them // create intermediary directories - sometimes zip don't add them
File dirF = fileUtils.getParentFile( f );
File dirF = f.getParentFile();
dirF.mkdirs(); dirF.mkdirs();


if( isDirectory ) if( isDirectory )


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Replace.java View File

@@ -296,7 +296,7 @@ public class Replace extends MatchingTask
} }


File temp = fileUtils.createTempFile( "rep", ".tmp", File temp = fileUtils.createTempFile( "rep", ".tmp",
fileUtils.getParentFile( src ) );
src.getParentFile() );


Reader reader = null; Reader reader = null;
Writer writer = null; Writer writer = null;


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -237,7 +237,7 @@ public class Zip extends MatchingTask
{ {
FileUtils fileUtils = FileUtils.newFileUtils(); FileUtils fileUtils = FileUtils.newFileUtils();
renamedFile = fileUtils.createTempFile( "zip", ".tmp", renamedFile = fileUtils.createTempFile( "zip", ".tmp",
fileUtils.getParentFile( zipFile ) );
zipFile.getParentFile() );


try try
{ {


+ 2
- 23
proposal/myrmidon/src/main/org/apache/tools/ant/util/FileUtils.java View File

@@ -38,7 +38,6 @@ import org.apache.tools.ant.types.FilterSetCollection;
public class FileUtils public class FileUtils
{ {
private static Random rand = new Random( System.currentTimeMillis() ); private static Random rand = new Random( System.currentTimeMillis() );
private static Object lockReflection = new Object();


/** /**
* Empty constructor. * Empty constructor.
@@ -57,26 +56,6 @@ public class FileUtils
return new FileUtils(); return new FileUtils();
} }


/**
* Emulation of File.getParentFile for JDK 1.1
*
* @param f Description of Parameter
* @return The ParentFile value
* @since 1.10
*/
public File getParentFile( File f )
{
if( f != null )
{
String p = f.getParent();
if( p != null )
{
return new File( p );
}
}
return null;
}

/** /**
* Compares the contents of two files. * Compares the contents of two files.
* *
@@ -300,7 +279,7 @@ public class FileUtils


// ensure that parent dir of dest file exists! // ensure that parent dir of dest file exists!
// not using getParentFile method to stay 1.1 compat // not using getParentFile method to stay 1.1 compat
File parent = getParentFile( destFile );
File parent = destFile.getParentFile();
if( !parent.exists() ) if( !parent.exists() )
{ {
parent.mkdirs(); parent.mkdirs();
@@ -577,7 +556,7 @@ public class FileUtils
String part = tok.nextToken(); String part = tok.nextToken();
if( part.equals( ".." ) ) if( part.equals( ".." ) )
{ {
helpFile = getParentFile( helpFile );
helpFile = helpFile.getParentFile();
if( helpFile == null ) if( helpFile == null )
{ {
String msg = "The file or path you specified (" String msg = "The file or path you specified ("


+ 2
- 2
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Available.java View File

@@ -275,7 +275,7 @@ public class Available
} }


FileUtils fileUtils = FileUtils.newFileUtils(); FileUtils fileUtils = FileUtils.newFileUtils();
File parent = fileUtils.getParentFile( path );
File parent = path.getParentFile();
// ** full-pathname specified == parent dir of path in list // ** full-pathname specified == parent dir of path in list
if( parent != null && parent.exists() if( parent != null && parent.exists()
&& file.equals( parent.getAbsolutePath() ) ) && file.equals( parent.getAbsolutePath() ) )
@@ -317,7 +317,7 @@ public class Available
// ** simple name specified == parent of parent dir + name // ** simple name specified == parent of parent dir + name
if( parent != null ) if( parent != null )
{ {
File grandParent = fileUtils.getParentFile( parent );
File grandParent = parent.getParentFile();
if( grandParent != null && grandParent.exists() ) if( grandParent != null && grandParent.exists() )
{ {
if( checkFile( new File( grandParent, file ), if( checkFile( new File( grandParent, file ),


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Expand.java View File

@@ -251,7 +251,7 @@ public class Expand extends MatchingTask
log( "expanding " + entryName + " to " + f, log( "expanding " + entryName + " to " + f,
Project.MSG_VERBOSE ); Project.MSG_VERBOSE );
// create intermediary directories - sometimes zip don't add them // create intermediary directories - sometimes zip don't add them
File dirF = fileUtils.getParentFile( f );
File dirF = f.getParentFile();
dirF.mkdirs(); dirF.mkdirs();


if( isDirectory ) if( isDirectory )


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Replace.java View File

@@ -296,7 +296,7 @@ public class Replace extends MatchingTask
} }


File temp = fileUtils.createTempFile( "rep", ".tmp", File temp = fileUtils.createTempFile( "rep", ".tmp",
fileUtils.getParentFile( src ) );
src.getParentFile() );


Reader reader = null; Reader reader = null;
Writer writer = null; Writer writer = null;


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -237,7 +237,7 @@ public class Zip extends MatchingTask
{ {
FileUtils fileUtils = FileUtils.newFileUtils(); FileUtils fileUtils = FileUtils.newFileUtils();
renamedFile = fileUtils.createTempFile( "zip", ".tmp", renamedFile = fileUtils.createTempFile( "zip", ".tmp",
fileUtils.getParentFile( zipFile ) );
zipFile.getParentFile() );


try try
{ {


+ 2
- 23
proposal/myrmidon/src/todo/org/apache/tools/ant/util/FileUtils.java View File

@@ -38,7 +38,6 @@ import org.apache.tools.ant.types.FilterSetCollection;
public class FileUtils public class FileUtils
{ {
private static Random rand = new Random( System.currentTimeMillis() ); private static Random rand = new Random( System.currentTimeMillis() );
private static Object lockReflection = new Object();


/** /**
* Empty constructor. * Empty constructor.
@@ -57,26 +56,6 @@ public class FileUtils
return new FileUtils(); return new FileUtils();
} }


/**
* Emulation of File.getParentFile for JDK 1.1
*
* @param f Description of Parameter
* @return The ParentFile value
* @since 1.10
*/
public File getParentFile( File f )
{
if( f != null )
{
String p = f.getParent();
if( p != null )
{
return new File( p );
}
}
return null;
}

/** /**
* Compares the contents of two files. * Compares the contents of two files.
* *
@@ -300,7 +279,7 @@ public class FileUtils


// ensure that parent dir of dest file exists! // ensure that parent dir of dest file exists!
// not using getParentFile method to stay 1.1 compat // not using getParentFile method to stay 1.1 compat
File parent = getParentFile( destFile );
File parent = destFile.getParentFile();
if( !parent.exists() ) if( !parent.exists() )
{ {
parent.mkdirs(); parent.mkdirs();
@@ -577,7 +556,7 @@ public class FileUtils
String part = tok.nextToken(); String part = tok.nextToken();
if( part.equals( ".." ) ) if( part.equals( ".." ) )
{ {
helpFile = getParentFile( helpFile );
helpFile = helpFile.getParentFile();
if( helpFile == null ) if( helpFile == null )
{ {
String msg = "The file or path you specified (" String msg = "The file or path you specified ("


Loading…
Cancel
Save