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