/*
 *  iReport  --  Visual designer for generating JasperReports Documents
 *  Copyright (C) 2002  Giulio Toffoli gt@businesslogic.it
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  Giulio Toffoli
 *  Via T.Aspetti, 233
 *  35100 Padova ITALY
 *  gt@businesslogic.it
 *
 *  Author:  Dominique Gallot
 */
package com.businesslogic.ireport.util;

import com.ms.wfc.app.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;
import com.ms.wfc.html.*;
import com.ms.wfc.io.*;

public class FileUtils
{
	public static boolean sameFile(String filename1, String filename2)
	{
	  // TODO write this better
		
	  File f1 = new File(filename1, FileMode.OPEN );
	  File f2 = new File(filename2, FileMode.OPEN );
	  if ( f1.getLength() != f2.getLength() )
	  {
  	    f1.close();
  	    f2.close();
		return false;
	  }
	  long len = f1.getLength();
	  		  
	  byte[] c1 = f1.readToEnd();
	  byte[] c2 = f2.readToEnd();
	  for ( int i = 0; ((i < c1.length ) && ( i < c2.length )); i++ )
	  {
		  if ( c1[i] != c2[i] )
		  {
 			f1.close();
			f2.close();
  			return false;
		  }
	  }
					    
	  f1.close();
	  f2.close();
	  return true;
		  
		 
	}
}

