@@ -22,22 +22,35 @@ var DEFAULT_SOURCETREE = '"<group>"',
2222 DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR' ,
2323 DEFAULT_FILEENCODING = 4 ,
2424 DEFAULT_GROUP = 'Resources' ,
25- DEFAULT_FILETYPE = 'unknown' ;
25+ DEFAULT_FILETYPE = 'unknown' ,
26+ HEADER_FILE_TYPE_SUFFIX = ".h" ,
27+ SOURCE_CODE_FILE_TYPE_PREFIX = "sourcecode." ;
2628
2729var FILETYPE_BY_EXTENSION = {
2830 a : 'archive.ar' ,
2931 app : 'wrapper.application' ,
3032 appex : 'wrapper.app-extension' ,
3133 bundle : 'wrapper.plug-in' ,
34+ c : 'sourcecode.c.c' ,
35+ cc : 'sourcecode.cpp.cpp' ,
36+ cpp : 'sourcecode.cpp.cpp' ,
37+ cxx : 'sourcecode.cpp.cpp' ,
38+ 'c++' : 'sourcecode.cpp.cpp' ,
3239 dylib : 'compiled.mach-o.dylib' ,
3340 framework : 'wrapper.framework' ,
3441 h : 'sourcecode.c.h' ,
42+ hh : 'sourcecode.cpp.h' ,
43+ hpp : 'sourcecode.cpp.h' ,
44+ hxx : 'sourcecode.cpp.h' ,
45+ 'h++' : 'sourcecode.cpp.h' ,
3546 m : 'sourcecode.c.objc' ,
47+ mm : 'sourcecode.cpp.objcpp' ,
3648 markdown : 'text' ,
3749 mdimporter : 'wrapper.cfbundle' ,
3850 octest : 'wrapper.cfbundle' ,
3951 pch : 'sourcecode.c.h' ,
4052 plist : 'text.plist.xml' ,
53+ png : "image.png" ,
4154 sh : 'text.script.sh' ,
4255 swift : 'sourcecode.swift' ,
4356 tbd : 'sourcecode.text-based-dylib-definition' ,
@@ -56,8 +69,11 @@ var FILETYPE_BY_EXTENSION = {
5669 'wrapper.framework' : 'Frameworks' ,
5770 'embedded.framework' : 'Embed Frameworks' ,
5871 'sourcecode.c.h' : 'Resources' ,
72+ 'sourcecode.c.c' : 'Sources' ,
5973 'sourcecode.c.objc' : 'Sources' ,
60- 'sourcecode.swift' : 'Sources'
74+ 'sourcecode.swift' : 'Sources' ,
75+ 'sourcecode.cpp.cpp' : 'Sources' ,
76+ 'sourcecode.cpp.objcpp' : 'Sources'
6177 } ,
6278 PATH_BY_FILETYPE = {
6379 'compiled.mach-o.dylib' : 'usr/lib/' ,
@@ -72,7 +88,11 @@ var FILETYPE_BY_EXTENSION = {
7288 ENCODING_BY_FILETYPE = {
7389 'sourcecode.c.h' : 4 ,
7490 'sourcecode.c.h' : 4 ,
91+ 'sourcecode.cpp.h' : 4 ,
92+ 'sourcecode.c.c' : 4 ,
7593 'sourcecode.c.objc' : 4 ,
94+ 'sourcecode.cpp.cpp' : 4 ,
95+ 'sourcecode.cpp.objcpp' : 4 ,
7696 'sourcecode.swift' : 4 ,
7797 'text' : 4 ,
7898 'text.plist.xml' : 4 ,
@@ -81,6 +101,13 @@ var FILETYPE_BY_EXTENSION = {
81101 'text.plist.strings' : 4
82102 } ;
83103
104+ function isSourceOrHeaderFileType ( fileType ) {
105+ return fileType . startsWith ( SOURCE_CODE_FILE_TYPE_PREFIX ) ;
106+ }
107+
108+ function isHeaderFileType ( fileType ) {
109+ return fileType . endsWith ( HEADER_FILE_TYPE_SUFFIX ) ;
110+ }
84111
85112function unquoted ( text ) {
86113 return text == null ? '' : text . replace ( / ( ^ " ) | ( " $ ) / g, '' )
@@ -186,7 +213,7 @@ function defaultGroup(fileRef) {
186213function pbxFile ( filepath , opt ) {
187214 var opt = opt || { } ;
188215
189- this . basename = path . basename ( filepath ) ;
216+ this . basename = opt . basename || path . basename ( filepath ) ;
190217 this . lastKnownFileType = opt . lastKnownFileType || detectType ( filepath ) ;
191218 this . group = detectGroup ( this , opt ) ;
192219
@@ -230,4 +257,8 @@ function pbxFile(filepath, opt) {
230257 }
231258}
232259
233- module . exports = pbxFile ;
260+ module . exports = {
261+ pbxFile : pbxFile ,
262+ isSourceOrHeaderFileType,
263+ isHeaderFileType
264+ }
0 commit comments