xref: /OpenGrok/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/IgnoredFiles.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) 2007, 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 file names (like "cscope.out"), SRC_ROOT
30  * relative file paths (like "usr/src/uts" or "usr/src/Makefile"), and glob
31  * patterns (like .make.*) which should be ignored.
32  *
33  * @author Chandan
34  */
35 public final class IgnoredFiles extends Filter {
36 
37     private static final long serialVersionUID = 3673125546519046976L;
38 
39     private static final String[] defaultPatternsFiles = {
40         "cscope.in.out",
41         "cscope.out.po",
42         "cscope.out.in",
43         "cscope.po.out",
44         "cscope.po.in",
45         "cscope.files",
46         "cscope.out",
47         "*~",
48         ".make.*",
49         ".del-*",
50         "_MTN",
51         ".vspscc", // Visual Studio
52         ".vssscc", // Visual Studio
53         ".suo", // Visual Studio user specific settings
54         ".user",
55         ".ncb",
56         ".gpState",  // Guidance automation toolkit (MS)
57         ".snc",
58         ".sln",
59         ".vsmdi", // Visual Studio tests
60         "*.dll",
61         "*.DLL",
62     };
63 
IgnoredFiles()64     public IgnoredFiles() {
65         super();
66         addDefaultPatterns();
67     }
68 
69     /**
70      * Should the file be ignored or not?
71      * @return {@code true} if {@code file} has {@link File#isFile() == true}
72      * and should be ignored per filtering
73      */
74     @Override
match(File file)75     public boolean match(File file) {
76         return file.isFile() && super.match(file);
77     }
78 
addDefaultPatterns()79     private void addDefaultPatterns() {
80         for (String s : defaultPatternsFiles) {
81             add(s);
82         }
83     }
84 }
85