Repository navigation
Expand file tree
/
Copy pathXcodeSourceFileType.m
More file actions
executable file
·96 lines (84 loc) · 2.96 KB
/
Copy pathXcodeSourceFileType.m
File metadata and controls
executable file
·96 lines (84 loc) · 2.96 KB
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
87
88
89
90
91
92
93
94
95
////////////////////////////////////////////////////////////////////////////////
//
// JASPER BLUES
// Copyright 2012 Jasper Blues
// All Rights Reserved.
//
// NOTICE: Jasper Blues permits you to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
#import "XcodeSourceFileType.h"
static NSDictionary* NSDictionaryWithXCFileReferenceTypes()
{
static NSDictionary* dictionary;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^
{
dictionary = @{
@"sourcecode.c.h" : @(SourceCodeHeader),
@"sourcecode.c.objc" : @(SourceCodeObjC),
@"wrapper.framework" : @(Framework),
@"text.plist.strings" : @(PropertyList),
@"sourcecode.cpp.objcpp" : @(SourceCodeObjCPlusPlus),
@"sourcecode.cpp.cpp" : @(SourceCodeCPlusPlus),
@"file.xib" : @(XibFile),
@"image.png" : @(ImageResourcePNG),
@"wrapper.cfbundle" : @(Bundle),
@"archive.ar" : @(Archive),
@"text.html" : @(HTML),
@"text" : @(TEXT),
@"wrapper.pb-project" : @(XcodeProject),
@"folder" : @(Folder),
@"folder.assetcatalog" : @(AssetCatalog),
@"sourcecode.swift" : @(SourceCodeSwift),
@"wrapper.application" : @(Application),
@"file.playground" : @(Playground),
@"text.script.sh" : @(ShellScript),
@"net.daringfireball.markdown" : @(Markdown),
@"text.plist.xml" : @(XMLPropertyList),
@"file.storyboard" : @(Storyboard)
};
});
return dictionary;
}
NSString* NSStringFromXCSourceFileType(XcodeSourceFileType type)
{
return [[NSDictionaryWithXCFileReferenceTypes() allKeysForObject:@(type)] objectAtIndex:0];
}
XcodeSourceFileType XCSourceFileTypeFromStringRepresentation(NSString* string)
{
NSDictionary* typeStrings = NSDictionaryWithXCFileReferenceTypes();
if (typeStrings[string])
{
return (XcodeSourceFileType) [typeStrings[string] intValue];
}
else
{
return FileTypeNil;
}
}
XcodeSourceFileType XCSourceFileTypeFromFileName(NSString* fileName)
{
if ([fileName hasSuffix:@".h"] || [fileName hasSuffix:@".hh"] || [fileName hasSuffix:@".hpp"] || [fileName hasSuffix:@".hxx"])
{
return SourceCodeHeader;
}
if ([fileName hasSuffix:@".c"] || [fileName hasSuffix:@".m"])
{
return SourceCodeObjC;
}
if ([fileName hasSuffix:@".mm"])
{
return SourceCodeObjCPlusPlus;
}
if ([fileName hasSuffix:@".cpp"])
{
return SourceCodeCPlusPlus;
}
if ([fileName hasSuffix:@".swift"])
{
return SourceCodeSwift;
}
return FileTypeNil;
}