1 15 16 30 package ixenon.free.nodes; 31 32 import java.io.*; 33 import java.util.*; 34 import java.awt.*; 35 import java.awt.event.*; 36 37 import javax.swing.*; import javax.swing.event.*; import javax.swing.tree.*; 41 import ixenon.free.swing.*; import ixenon.free.install.*; 44 48 public class SimpleCopyFile extends AbstractInstallable 49 implements Installable 50 { 51 52 protected File sourceFile; 53 54 protected File targetFile; 55 56 protected int perms; 57 58 66 public SimpleCopyFile( String nodeName, 67 int perms, 68 String sourceFile, 69 String targetFile ) 70 { 71 this( nodeName, perms, new File(sourceFile), new File(targetFile) ); 72 } 73 74 82 public SimpleCopyFile( String nodeName, 83 int perms, 84 File sourceFile, 85 File targetFile ) 86 { 87 super( nodeName, null, true ); 88 this.sourceFile = sourceFile; 89 this.targetFile = targetFile; 90 this.perms = perms; 91 } 92 93 97 public Component getVisualComponent() 98 { 99 return (null); 100 } 101 102 106 public Component getConfigurableComponent() 107 { 108 return (null); 109 } 110 111 112 118 public void install() throws InstallException 119 { 120 FreeInstallerApplication theApp = 121 FreeInstallerApplication.getInstance(); 122 123 JProgressBar pbarFile = theApp.getProgressFrame().getProgressBarFile(); 124 125 if ( !sourceFile.exists() ) 126 throw new InstallException("no such file:`"+sourceFile.getAbsolutePath()+"'" ); 127 if ( sourceFile.isDirectory() ) 128 throw new InstallException("cannot copy a directory:`"+sourceFile.getAbsolutePath()+"'" ); 129 if ( targetFile.isDirectory() ) 130 throw new InstallException("cannot copy a directory:`"+targetFile.getAbsolutePath()+"'" ); 131 132 theApp.printInfo( "simple file copy:`" + sourceFile.getPath() + "' to `" + targetFile.getPath()+"'" ); 133 boolean status = InstallUtilities.copyFile( 134 pbarFile, sourceFile, targetFile, true ); 135 if (status) { 136 InstallUtilities.setFilePermissions( targetFile, perms ); 137 138 uninstallable.addFile( targetFile ); 140 } 141 else { 142 theApp.printWarning( "failure to copy:`" + sourceFile.getPath() + "' to `" + targetFile.getPath()+"'" ); 143 if (pedantic) 144 throw new InstallException( "failure to copy:`" + sourceFile.getPath() + "' to `" + targetFile.getPath()+"'" ); 145 } 146 } 147 148 151 public void cleanup() throws InstallException 152 { 153 } 155 156 } 157 | Popular Tags |