xref: /OpenGrok/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/IgnoredDirs.java (revision 5d9f3aa0ca3da3a714233f987fa732f62c0965f6)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * See LICENSE.txt included in this distribution for the specific
9  * language governing permissions and limitations under the License.
10  *
11  * When distributing Covered Code, include this CDDL HEADER in each
12  * file and include the License file at LICENSE.txt.
13  * If applicable, add the following below this CDDL HEADER, with the
14  * fields enclosed by brackets "[]" replaced with your own identifying
15  * information: Portions Copyright [yyyy] [name of copyright owner]
16  *
17  * CDDL HEADER END
18  */
19 
20 /*
21  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
22  * Portions Copyright (c) 2019, 2020, Chris Fraire <cfraire@me.com>.
23  */
24 package org.opengrok.indexer.configuration;
25 
26 import java.io.File;
27 
28 /**
29  * This class maintains a list of directory names, SRC_ROOT
30  * relative file paths (like "usr/src/uts"), and glob
31  * patterns (like .make.*) which opengrok should ignore.
32  *
33  * @author Chandan
34  */
35 public final class IgnoredDirs extends Filter {
36     private static final long serialVersionUID = -6771850658877396699L;
37 
38     private static final String[] defaultPatternsDirs = {
39         "Codemgr_wsdata", // Teamware
40         "deleted_files",  // Teamware
41     };
42 
IgnoredDirs()43     public IgnoredDirs() {
44         super();
45         addDefaultPatterns();
46     }
47 
48     /**
49      * Should the file (that must be a directory) be ignored or not?
50      * @return {@code true} if {@code file} has
51      * {@link File#isDirectory()} () == true} and should be ignored per
52      * filtering
53      */
54     @Override
match(File file)55     public boolean match(File file) {
56         return file.isDirectory() && super.match(file);
57     }
58 
addDefaultPatterns()59     private void addDefaultPatterns() {
60         for (String s : defaultPatternsDirs) {
61             add(s);
62         }
63     }
64 }
65