Changeset 19755 for release-kits/shared/core
- Timestamp:
- 2009-06-08T13:34:49+12:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
release-kits/shared/core/ant-installer/src/org/tp23/antinstaller/input/DirectoryInput.java
r17832 r19755 17 17 18 18 import java.io.File; 19 import java.io.IOException; 19 20 import java.util.ResourceBundle; 21 import java.util.ArrayList; 20 22 21 23 import org.tp23.antinstaller.InstallerContext; … … 37 39 private String create; 38 40 private String checkExists; 41 42 //to make default install directory choice smart 43 private String decidedDefault = null; 39 44 40 45 //to detect previous installations … … 98 103 } 99 104 105 public String getDefaultValue(boolean correctForOS) { 106 107 if ( this.defaultValue == null ) { 108 return null; 109 } 110 111 if ( decidedDefault != null ) { 112 return decidedDefault; 113 } 114 115 String[] defaultsArray = defaultValue.split(","); 116 for ( int i=0; i<defaultsArray.length; i++ ) { 117 String def = resultContainer.getDefaultFileRef(defaultsArray[i]); 118 File defFile = new File( def ); 119 120 //if the path is a file, go to next 121 if ( defFile.isFile() ) { 122 continue; 123 } 124 125 //if the path is a directory, try to write a little file to it 126 if ( defFile.isDirectory() ) { 127 File testFile = new File( defFile, "ant-installer-test-file-(ok-to-delete)" ); 128 boolean result = false; 129 try { result = testFile.createNewFile(); } catch ( IOException ioe ) {} 130 if ( result ) { 131 decidedDefault = def; 132 try { testFile.delete(); } catch ( SecurityException se ) {} 133 return decidedDefault; 134 } 135 } 136 137 //if the path doesn't exist, try to create it as a directory 138 if ( !defFile.exists() ) { 139 if ( defFile.mkdir() ) { 140 decidedDefault = def; 141 try { defFile.delete(); } catch ( SecurityException se ) {} 142 return decidedDefault; 143 } 144 } 145 146 } 147 148 decidedDefault = resultContainer.getDefaultFileRef( 149 defaultsArray[defaultsArray.length-1] 150 ); 151 return decidedDefault; 152 153 } 154 100 155 public boolean isAbort() { 101 156 return abort; … … 154 209 return false; 155 210 } 156 if( getDefaultValue()== null){211 if(defaultValue == null){ 157 212 System.out.println("Directory:defaultValue must be set"); 158 213 return false; 159 214 } 160 if( getDefaultValue().equals("")){215 if(defaultValue.equals("")){ 161 216 if( isTrue(getCreate()) || isTrue(getCheckExists()) ) { 162 217 System.out.println("Directory:defaultValue must be set if checkExists or create are true");
Note:
See TracChangeset
for help on using the changeset viewer.