X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=source%2Fmir%2Futil%2FFileFunctions.java;h=7ade9aa2546eb14dd77d74fc2dad57a55809cafd;hb=6b6b6215ebe066b81f1fa6b0c71a532ca7b4fc3f;hp=20d20e5c4508dcb8535db8168b84d2c9daeb3418;hpb=55d545036aa5c04676f2d20f0e98316a4679ec27;p=mir.git diff --git a/source/mir/util/FileFunctions.java b/source/mir/util/FileFunctions.java index 20d20e5c..7ade9aa2 100755 --- a/source/mir/util/FileFunctions.java +++ b/source/mir/util/FileFunctions.java @@ -1,109 +1,37 @@ +/* + * Copyright (C) 2005 The Mir-coders group + * + * This file is part of Mir. + * + * Mir 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. + * + * Mir 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 Mir; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, The Mir-coders gives permission to link + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. + * If you do not wish to do so, delete this exception statement from your version. + */ package mir.util; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.FilenameFilter; - -import gnu.regexp.RE; - -public class FileFunctions { - protected static final int FILE_COPY_BUFFER_SIZE = 65536; - - private FileFunctions() { - } - - public static void copyFile(File aSourceFile, File aDestinationFile) throws IOException { - FileInputStream inputStream; - FileOutputStream outputStream; - int nrBytesRead; - byte[] buffer = new byte[FILE_COPY_BUFFER_SIZE]; - - inputStream = new FileInputStream(aSourceFile); - try { - File directory = new File(aDestinationFile.getParent()); - if (directory!=null && !directory.exists()){ - directory.mkdirs(); - } - outputStream = new FileOutputStream(aDestinationFile); - try { - do { - nrBytesRead = inputStream.read(buffer); - if (nrBytesRead>0) - outputStream.write(buffer, 0, nrBytesRead); - } - while (nrBytesRead>=0); - } - finally { - outputStream.close(); - } - } - finally { - inputStream.close(); - } - } - - public static void copyDirectory(File aSourceDirectory, File aDestinationDirectory) throws IOException { - int i; - File sourceFile; - File destinationFile; - File[] files = aSourceDirectory.listFiles(); - - if (!aDestinationDirectory.exists()) - aDestinationDirectory.mkdirs(); - - for (i=0; i