summaryrefslogtreecommitdiff
path: root/src/YalpServer/FileFinder.java
diff options
context:
space:
mode:
authorguest <guest@f059d3a0-6783-47b7-97ff-1fe0bbf25129>2008-09-24 18:38:34 +0000
committerguest <guest@f059d3a0-6783-47b7-97ff-1fe0bbf25129>2008-09-24 18:38:34 +0000
commitf6825ebc115029fcf575033748e3372efb94c87d (patch)
treeb2f73b306231a6d108d3d85695f2c6f2622eecd4 /src/YalpServer/FileFinder.java
parent057fd35e1a6186c2ca2859152b30eccbff514f10 (diff)
removed classes, which shouldn't be part of the server in yalp2.0
git-svn-id: http://manut.eu/svn/yalp/trunk@4 f059d3a0-6783-47b7-97ff-1fe0bbf25129
Diffstat (limited to 'src/YalpServer/FileFinder.java')
-rwxr-xr-xsrc/YalpServer/FileFinder.java110
1 files changed, 0 insertions, 110 deletions
diff --git a/src/YalpServer/FileFinder.java b/src/YalpServer/FileFinder.java
deleted file mode 100755
index 2d6527c..0000000
--- a/src/YalpServer/FileFinder.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/***********************************************************************
- *
- * Copyright (c) 2006 Manuel Traut and Volker Dahnke
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors: Manuel Traut and Volker Dahnke
- *
- ***********************************************************************/
-package YalpServer;
-
-import java.io.*;
-import java.util.*;
-
-/************************************************************************
- *
- * Class FileFinder
- *
- * <em>algorithm for scanning files recursively</em>
- *
- * @author Volker Dahnke / Manuel Traut
- *
- * @version 0.6 14-12-2005<br>
- *
- * @see FileBrowser
- *
- ************************************************************************/
-
-public class FileFinder
-{
- private ArrayList<File> files;
-
- /**
- * Constructor: scans subdirectories of commited directory
- * uses only files with allowed extensions
- * @param start
- * directory to scan
- * @param extensions
- * allowed extensions
- */
- public FileFinder( String start, String extensions[] ) {
-
- this.files = new ArrayList<File>();
- Stack<File> dirs = new Stack<File>();
- File startdir = new File(start);
-
- // push startdir to stack
- if (startdir.isDirectory()) dirs.push(startdir);
- // startdir is File
- else {
- if (match(startdir.getName(), extensions)) this.files.add(startdir);
- return;
- }
- // for each dir on stack
- while (dirs.size() > 0) {
- // contents of dir on stack
- for (File file : dirs.pop().listFiles()){
- try {
- // add subdirectory to stack
- if (file.isDirectory()) dirs.push(file);
- // if file is of correct filetype add it to filelist
- else if (match(file.getName(), extensions)) this.files.add(file);
- } catch (NullPointerException e) {
- System.out.println("FileFinder: "+ file.getName() +"Premission denied");
- }
- }
- }
- }
-
- /**
- * returns and prints out all Medias found
- * @return ArrayList<File>
- * all found Medias
- */
- public ArrayList<File> getFiles(){
- print();
- return this.files;
- }
-
- /**
- * prints out found medias
- *
- */
- public void print() {
- System.out.println( "Found " + files.size() + " file" + (files.size() == 1 ? "." : "s.") );
- for ( File f : files ) System.out.println( f.getAbsolutePath() );
- }
-
- /**
- * checks if file extension matches or not
- *
- * @param s
- * file to check
- * @param suffixes
- * allowed extensions
- *
- * @return boolean: true if it's a media, yalp can handle
- */
- private static boolean match( String s, String suffixes[] ) {
- for ( String suffix : suffixes ) {
- int huhu = s.length();
- int huhu2 = suffix.length();
- int huhu3 = huhu - huhu2;
- if ( s.length() >= suffix.length() && s.substring(huhu3, s.length()).equalsIgnoreCase(suffix) ) return true;
- }
- return false;
- }
-}