-
Notifications
You must be signed in to change notification settings - Fork 0
/
source_file_type.go
43 lines (33 loc) · 1.24 KB
/
source_file_type.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
package main
import "path/filepath"
// SourceFileType specifies the file type to associate with the file extension.
type SourceFileType int
const (
// SourceFileTypeUnknown indicates the file type is unknown.
SourceFileTypeUnknown SourceFileType = iota
// SourceFileTypeCppSource indicates the file is a C++ source file.
SourceFileTypeCppSource
// SourceFileTypeCppHeader indicates the file is a C++ header file.
SourceFileTypeCppHeader
// SourceFileTypeCSource indicates the file is a C source file.
SourceFileTypeCSource
// SourceFileTypeObjC indicates the file is a Objective-C source file.
SourceFileTypeObjC
// SourceFileTypeObjCpp indicates the file is a Objective-C++ source file.
SourceFileTypeObjCpp
)
func getSourceFileType(filename string) SourceFileType {
ext := filepath.Ext(filename)
if ext == ".cpp" || ext == ".cc" || ext == ".cxx" || ext == ".c++" {
return SourceFileTypeCppSource
} else if ext == ".c" {
return SourceFileTypeCSource
} else if ext == ".h" || ext == ".hh" || ext == ".hpp" || ext == ".hxx" || ext == ".inc" || ext == ".ipp" {
return SourceFileTypeCppHeader
} else if ext == ".m" {
return SourceFileTypeObjC
} else if ext == ".mm" {
return SourceFileTypeObjCpp
}
return SourceFileTypeUnknown
}