Repository navigation
Expand file tree
/
Copy pathSXCXcodeFileType.m
More file actions
executable file
·80 lines (69 loc) · 2.75 KB
/
Copy pathSXCXcodeFileType.m
File metadata and controls
executable file
·80 lines (69 loc) · 2.75 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
////////////////////////////////////////////////////////////////////////////////
//
// 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 "SXCXcodeFileType.h"
static NSDictionary* SXCNSDictionaryWithXCFileReferenceTypes()
{
static NSDictionary* dictionary;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
dictionary = @{
@"sourcecode.c.h" : @(SXCXcodeFileTypeSourceCodeHeader),
@"sourcecode.c.objc" : @(SXCXcodeFileTypeSourceCodeObjC),
@"wrapper.framework" : @(SXCXcodeFileTypeFramework),
@"text.plist.strings" : @(SXCXcodeFileTypePropertyList),
@"sourcecode.cpp.objcpp" : @(SXCXcodeFileTypeSourceCodeObjCPlusPlus),
@"sourcecode.cpp.cpp" : @(SXCXcodeFileTypeSourceCodeCPlusPlus),
@"file.xib" : @(SXCXcodeFileTypeXibFile),
@"image.png" : @(SXCXcodeFileTypeImageResourcePNG),
@"wrapper.cfbundle" : @(SXCXcodeFileTypeBundle),
@"archive.ar" : @(SXCXcodeFileTypeArchive),
@"text.html" : @(SXCXcodeFileTypeHTML),
@"text" : @(SXCXcodeFileTypeTEXT),
@"wrapper.pb-project" : @(SXCXcodeFileTypeXcodeProject),
@"folder" : @(SXCXcodeFileTypeFolder)
};
});
return dictionary;
}
NSString* SXCNSStringFromSXCXcodeFileType(SXCXcodeFileType type)
{
return [[SXCNSDictionaryWithXCFileReferenceTypes() allKeysForObject:@(type)] firstObject];
}
SXCXcodeFileType SXCXcodeFileTypeFromStringRepresentation(NSString* string)
{
NSDictionary* typeStrings = SXCNSDictionaryWithXCFileReferenceTypes();
NSNumber* typeValue = typeStrings[string];
if (typeValue) {
return (SXCXcodeFileType) [typeValue intValue];
} else {
return SXCXcodeFileTypeNil;
}
}
SXCXcodeFileType SXCXcodeFileTypeFromFileName(NSString* fileName)
{
if ([fileName hasSuffix:@".h"] ||
[fileName hasSuffix:@".hh"] ||
[fileName hasSuffix:@".hpp"] ||
[fileName hasSuffix:@".hxx"]) {
return SXCXcodeFileTypeSourceCodeHeader;
}
if ([fileName hasSuffix:@".c"] ||
[fileName hasSuffix:@".m"]) {
return SXCXcodeFileTypeSourceCodeObjC;
}
if ([fileName hasSuffix:@".mm"]) {
return SXCXcodeFileTypeSourceCodeObjCPlusPlus;
}
if ([fileName hasSuffix:@".cpp"]) {
return SXCXcodeFileTypeSourceCodeCPlusPlus;
}
return SXCXcodeFileTypeNil;
}