~ubuntu-branches/ubuntu/trusty/pylucene/trusty

« back to all changes in this revision

Viewing changes to lucene-java-2.3.1/contrib/benchmark/src/java/org/apache/lucene/benchmark/AbstractBenchmarker.java

  • Committer: Package Import Robot
  • Author(s): Dmitry Nezhevenko
  • Date: 2012-04-23 16:43:55 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120423164355-grqtepnwtecdjfk2
Tags: 3.5.0-1
* New maintainer (closes: 670179)
* New upstream release
* Switch to dpkg-source 3.0 (quilt) format
* Switch to machine-readable debian/copyright
* Bump debian/compat to 8, drop debian/pycompat
* Switch from cdbs to dh
* Add watch file
* Build for all supported versions of python2 (closes: 581198, 632240)
* Rename binary package to python-lucene (closes: 581197)
* Add -dbg package

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.apache.lucene.benchmark;
2
 
 
3
 
import java.io.File;
4
 
import java.io.IOException;
5
 
/**
6
 
 * Copyright 2005 The Apache Software Foundation
7
 
 *
8
 
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 
 * you may not use this file except in compliance with the License.
10
 
 * You may obtain a copy of the License at
11
 
 *
12
 
 *     http://www.apache.org/licenses/LICENSE-2.0
13
 
 *
14
 
 * Unless required by applicable law or agreed to in writing, software
15
 
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 
 * See the License for the specific language governing permissions and
18
 
 * limitations under the License.
19
 
 */
20
 
 
21
 
 
22
 
/**
23
 
 *
24
 
 * @deprecated Use the Task based benchmarker
25
 
 **/
26
 
public abstract class AbstractBenchmarker implements Benchmarker
27
 
{
28
 
    /**
29
 
     * Delete files and directories, even if non-empty.
30
 
     *
31
 
     * @param dir file or directory
32
 
     * @return true on success, false if no or part of files have been deleted
33
 
     * @throws java.io.IOException
34
 
     */
35
 
    public static boolean fullyDelete(File dir) throws IOException
36
 
    {
37
 
        if (dir == null || !dir.exists()) return false;
38
 
        File contents[] = dir.listFiles();
39
 
        if (contents != null)
40
 
        {
41
 
            for (int i = 0; i < contents.length; i++)
42
 
            {
43
 
                if (contents[i].isFile())
44
 
                {
45
 
                    if (!contents[i].delete())
46
 
                    {
47
 
                        return false;
48
 
                    }
49
 
                }
50
 
                else
51
 
                {
52
 
                    if (!fullyDelete(contents[i]))
53
 
                    {
54
 
                        return false;
55
 
                    }
56
 
                }
57
 
            }
58
 
        }
59
 
        return dir.delete();
60
 
    }
61
 
}