AMADEUS html plain
import java . io . File ;
import java . io . FileInputStream ;
import java . io . FileOutputStream ;
class FileCopier
class FileCopier
private String sourceBaseLanguage ;
needed for sketchify and maybe for
textualizing too
private String modelBaseLanguage ;
for model verifying and maybe for
textualizing
FileCopier
public
FileCopier ( String sourceBl , String modelBl )
this . sourceBaseLanguage = sourceBl ;
this . modelBaseLanguage = modelBl ;
/**
/**
* Copies model file for this converter
* @throws Exception
*/
void copyAmadeusModelFile
public
void copyAmadeusModelFile ( File sFile , File rDir ) throws Exception
String rDirStr = rDir . getAbsolutePath ( ) ;
..if
? ! ( rDirStr . endsWith ( System . getProperty ( "file.separator" ) ) )
rDirStr += System . getProperty ( "file.separator" ) ;
rDirStr += sFile . getName ( ) ;
binaryCopy ( sFile . getAbsolutePath ( ) , rDirStr ) ;
/**
/**
* Used to copy Amadeus system classfiles
* @param sDir
* @param rDir
* @throws Exception
*/
void copyAmadeusClassFiles
public
void copyAmadeusClassFiles ( File sDir , File rDir ) throws Exception
File [ ] files ;
String sDirPath = sDir . getAbsolutePath ( ) ;
String rDirPath = rDir . getAbsolutePath ( ) ;
System . out . println ( sDirPath + " " + rDirPath ) ;
..if
? ! ( rDirPath . endsWith ( System . getProperty ( "file.separator" ) ) )
rDirPath += System . getProperty ( "file.separator" ) ;
..if
? ! ( rDir . exists ( ) )
boolean r = rDir . mkdirs ( ) ;
System . out . println ( "Tryed to create " + rDir + " and result = " + r ) ;
files = sDir . listFiles ( ) ;
System . out . println ( "files.length= " + files . length ) ;
..for
* int i = 0 ; i < files . length ; i ++
File f = files [ i ] ;
? f . isDirectory ( )
copyAmadeusClassFiles ( f , new File ( rDirPath + f . getName ( ) ) ) ;
<------
binaryCopy ( f . getAbsolutePath ( ) , rDirPath + f . getName ( ) ) ;
System . out . println ( "FileCopier@: Class files copied" ) ;
/**
/**
* Copies data from infile to outfile in binary mode
*/
void binaryCopy
private static
void binaryCopy ( String inputFile , String outputFile )
byte [ ] data = new byte [ 1024 ] ;
int readBytes ;
..try
!!
FileInputStream in = new FileInputStream ( new File ( inputFile ) ) ;
FileOutputStream out = new FileOutputStream ( new File ( outputFile ) ) ;
..for
* ; ( readBytes = in . read ( data ) ) != - 1 ;
out . write ( data , 0 , readBytes ) ;
in . close ( ) ;
out . close ( ) ;
..catch
! Exception e
e . printStackTrace ( ) ;
boolean canCopy
public static
boolean canCopy ( File sDir , File rDir )
? sDir . isDirectory ( ) && rDir . isDirectory ( )
String sDirPath = sDir . getAbsolutePath ( ) ;
String rDirPath = rDir . getAbsolutePath ( ) ;
..if
? rDirPath . startsWith ( sDirPath )
<==========( false )
<======( true )
<======( true )