-
Notifications
You must be signed in to change notification settings - Fork 0
/
classify.go
86 lines (76 loc) · 1.7 KB
/
classify.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// dcc - dependency-driven C/C++ compiler front end
//
// Copyright © A.Newman 2015.
//
// This source code is released under version 2 of the GNU Public License.
// See the file LICENSE for details.
//
package main
import (
"path/filepath"
)
var cppSet = MakeStringSet(
".c++",
".cc",
".cpp",
".cxx",
".h++",
".hh",
".hpp",
".hxx",
)
var sourceFileSet = MakeStringSet(
".c",
".c++",
".cc",
".cpp",
".cxx",
".m",
".mm",
)
var headerFileSet = MakeStringSet(
".h",
".h++",
".hh",
".hpp",
".hxx",
)
// IsCPlusPlusFile returns true if the supplied pathname is that
// of a C++ source file.
//
func IsCPlusPlusFile(path string) bool {
return cppSet.Contains(LowercaseFilenameExtension(path))
}
// IsSourceFile returns true if the supplied pathname is that
// of a C, C++ or Objective-C source file.
//
func IsSourceFile(path string) bool {
return sourceFileSet.Contains(LowercaseFilenameExtension(path))
}
// IsHeaderFile returns true if the supplied pathname is that
// of a C/C++ header file.
//
func IsHeaderFile(path string) bool {
return headerFileSet.Contains(LowercaseFilenameExtension(path))
}
// IsLibraryFile returns true if the supplied pathname is
// that of a library of some kind?
//
func IsLibraryFile(path string) bool {
ext := filepath.Ext(path)
if ext == platform.StaticLibSuffix {
return true
}
if ext == platform.DynamicLibSuffix {
return true
}
return false
}
// FileWillBeCompiled returns true if the supplied pathname is the
// name of a some source file that the compiler would compile.
// Header files are considered source files to accomodate pre-
// compiling header files.
//
func FileWillBeCompiled(path string) bool {
return IsSourceFile(path) || IsHeaderFile(path)
}