Skip to content

Package: FileUtil

FileUtil

nameinstructionbranchcomplexitylinemethod
delete(File)
M: 48 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * David Soto Setzke - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.ecore.editor.test;
15:
16: import java.io.File;
17:
18: /**
19: * File utility class.
20: */
21: public final class FileUtil {
22:
23:         private FileUtil() {
24:
25:         }
26:
27:         /**
28:          * Deletes the given file.
29:          *
30:          * @param fileToBeDeleted
31:          * the file to be deleted
32:          * @return {@code true}, if the file was successfully deleted, {@code false} otherwise
33:          */
34:         public static boolean delete(File fileToBeDeleted) {
35:•                if (fileToBeDeleted.isDirectory()) {
36:•                        if (fileToBeDeleted.list().length == 0) {
37:                                 return fileToBeDeleted.delete();
38:                         }
39:•                        for (final String temp : fileToBeDeleted.list()) {
40:                                 final File fileDelete = new File(fileToBeDeleted, temp);
41:                                 delete(fileDelete);
42:                         }
43:•                        if (fileToBeDeleted.list().length == 0) {
44:                                 fileToBeDeleted.delete();
45:                         }
46:                         return true;
47:                 }
48:                 return fileToBeDeleted.delete();
49:         }
50: }