Skip to content

Commit

Permalink
adding CWPathUtilities & doing some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Machx committed Dec 20, 2010
1 parent c7e6680 commit 7687e15
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 10 deletions.
16 changes: 16 additions & 0 deletions Source/CWPathUtilities.h
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// CWPathUtilities.h
// Zangetsu
//
// Created by Colin Wheeler on 12/20/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>

#define CWFullPathFromTildeString(_X_) [_X_ stringByExpandingTildeInPath]

@interface CWPathUtilities : NSObject {}
+(NSString *)applicationSupportFolder;
+(NSString *)pathByAppendingAppSupportFolderWithPath:(NSString *)path;
@end
30 changes: 30 additions & 0 deletions Source/CWPathUtilities.m
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// CWPathUtilities.m
// Zangetsu
//
// Created by Colin Wheeler on 12/20/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "CWPathUtilities.h"


@implementation CWPathUtilities

+(NSString *)applicationSupportFolder
{
NSString *_path = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) cw_firstObject];

return _path;
}

+(NSString *)pathByAppendingAppSupportFolderWithPath:(NSString *)path
{
NSString *_appSupportPath = [CWPathUtilities applicationSupportFolder];

NSString *_result = [NSString stringWithFormat:@"%@/%@",_appSupportPath,path];

return _result;
}

@end
3 changes: 0 additions & 3 deletions Source/NSStringAdditions.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@


#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>


//TODO: move this to its own path utilities class rather than NSString
#define CWFullPathFromTildeString(_X_) [_X_ stringByExpandingTildeInPath]

@interface NSString (CWNSStringAdditions) @interface NSString (CWNSStringAdditions)


+(NSString *)cw_uuidString; +(NSString *)cw_uuidString;
Expand Down
12 changes: 6 additions & 6 deletions Source/NSURLConnectionAdditions.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ +(void)cw_performAsynchronousRequest:(NSURLRequest *)request
[queue addOperationWithBlock:^() { [queue addOperationWithBlock:^() {


NSURLResponse *_response = nil; NSURLResponse *_response = nil;
NSError *_error = nil; NSError *_urlError = nil;


NSData *_data = [NSURLConnection sendSynchronousRequest:request NSData *_data = [NSURLConnection sendSynchronousRequest:request
returningResponse:&_response returningResponse:&_response
error:&_error]; error:&_urlError];


[[NSOperationQueue mainQueue] addOperationWithBlock:^() { [[NSOperationQueue mainQueue] addOperationWithBlock:^() {
block(_data,_response,_error); block(_data,_response,_urlError);
}]; }];
}]; }];
} }
Expand All @@ -54,14 +54,14 @@ +(void)cw_performAsynchronousRequest:(NSURLRequest *)request
dispatch_async(queue, ^{ dispatch_async(queue, ^{


NSURLResponse *_response = nil; NSURLResponse *_response = nil;
NSError *_error = nil; NSError *_urlError = nil;


NSData *_data = [NSURLConnection sendSynchronousRequest:request NSData *_data = [NSURLConnection sendSynchronousRequest:request
returningResponse:&_response returningResponse:&_response
error:&_error]; error:&_urlError];


dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
block(_data,_response,_error); block(_data,_response,_urlError);
}); });
}); });
} }
Expand Down
1 change: 1 addition & 0 deletions Zangetsu.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
#import "CWDebugUtilities.h" #import "CWDebugUtilities.h"
#import "NSObjectAdditions.h" #import "NSObjectAdditions.h"
#import "CWFoundation.h" #import "CWFoundation.h"
#import "CWPathUtilities.h"
8 changes: 8 additions & 0 deletions Zangetsu.xcodeproj/project.pbxproj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
B890149511D99D6A00705CE4 /* CWMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = B890149311D99D6A00705CE4 /* CWMacros.h */; settings = {ATTRIBUTES = (Public, ); }; }; B890149511D99D6A00705CE4 /* CWMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = B890149311D99D6A00705CE4 /* CWMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
B8C320CF12A1B77F00219E4A /* CWNSArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B8C320CE12A1B77F00219E4A /* CWNSArrayTests.m */; }; B8C320CF12A1B77F00219E4A /* CWNSArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B8C320CE12A1B77F00219E4A /* CWNSArrayTests.m */; };
B8E9142F12BD8C7400167AE8 /* CWNSObjectTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B8E9141412BD8B0A00167AE8 /* CWNSObjectTests.m */; }; B8E9142F12BD8C7400167AE8 /* CWNSObjectTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B8E9141412BD8B0A00167AE8 /* CWNSObjectTests.m */; };
B8E914CA12BFF5C000167AE8 /* CWPathUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = B8E914C812BFF5C000167AE8 /* CWPathUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; };
B8E914CB12BFF5C000167AE8 /* CWPathUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = B8E914C912BFF5C000167AE8 /* CWPathUtilities.m */; };
B8F5E68812A0301A00E58C94 /* CWDictionaryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B8F5E68712A0301A00E58C94 /* CWDictionaryTests.m */; }; B8F5E68812A0301A00E58C94 /* CWDictionaryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B8F5E68712A0301A00E58C94 /* CWDictionaryTests.m */; };
B8F5E6C512A0343900E58C94 /* Zangetsu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Zangetsu.framework */; }; B8F5E6C512A0343900E58C94 /* Zangetsu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Zangetsu.framework */; };
B8F5E6E412A0355900E58C94 /* CWSetTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B8F5E6E312A0355900E58C94 /* CWSetTests.m */; }; B8F5E6E412A0355900E58C94 /* CWSetTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B8F5E6E312A0355900E58C94 /* CWSetTests.m */; };
Expand Down Expand Up @@ -103,6 +105,8 @@
B8C320CE12A1B77F00219E4A /* CWNSArrayTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CWNSArrayTests.m; path = Source/CWNSArrayTests.m; sourceTree = "<group>"; }; B8C320CE12A1B77F00219E4A /* CWNSArrayTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CWNSArrayTests.m; path = Source/CWNSArrayTests.m; sourceTree = "<group>"; };
B8E9141312BD8B0A00167AE8 /* CWNSObjectTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CWNSObjectTests.h; path = Source/CWNSObjectTests.h; sourceTree = "<group>"; }; B8E9141312BD8B0A00167AE8 /* CWNSObjectTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CWNSObjectTests.h; path = Source/CWNSObjectTests.h; sourceTree = "<group>"; };
B8E9141412BD8B0A00167AE8 /* CWNSObjectTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CWNSObjectTests.m; path = Source/CWNSObjectTests.m; sourceTree = "<group>"; }; B8E9141412BD8B0A00167AE8 /* CWNSObjectTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CWNSObjectTests.m; path = Source/CWNSObjectTests.m; sourceTree = "<group>"; };
B8E914C812BFF5C000167AE8 /* CWPathUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CWPathUtilities.h; path = Source/CWPathUtilities.h; sourceTree = "<group>"; };
B8E914C912BFF5C000167AE8 /* CWPathUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CWPathUtilities.m; path = Source/CWPathUtilities.m; sourceTree = "<group>"; };
B8F5E66912A02EB400E58C94 /* Unit Tests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Unit Tests.octest"; sourceTree = BUILT_PRODUCTS_DIR; }; B8F5E66912A02EB400E58C94 /* Unit Tests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Unit Tests.octest"; sourceTree = BUILT_PRODUCTS_DIR; };
B8F5E66A12A02EB400E58C94 /* Unit Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Unit Tests-Info.plist"; sourceTree = "<group>"; }; B8F5E66A12A02EB400E58C94 /* Unit Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Unit Tests-Info.plist"; sourceTree = "<group>"; };
B8F5E68612A0301A00E58C94 /* CWDictionaryTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CWDictionaryTests.h; path = Source/CWDictionaryTests.h; sourceTree = "<group>"; }; B8F5E68612A0301A00E58C94 /* CWDictionaryTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CWDictionaryTests.h; path = Source/CWDictionaryTests.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -195,6 +199,8 @@
B8806A6812B3E88500F85BCE /* CWDebugUtilities.m */, B8806A6812B3E88500F85BCE /* CWDebugUtilities.m */,
B857FD0D12BA8E46001AA9A9 /* CWFoundation.h */, B857FD0D12BA8E46001AA9A9 /* CWFoundation.h */,
B857FD0E12BA8E46001AA9A9 /* CWFoundation.m */, B857FD0E12BA8E46001AA9A9 /* CWFoundation.m */,
B8E914C812BFF5C000167AE8 /* CWPathUtilities.h */,
B8E914C912BFF5C000167AE8 /* CWPathUtilities.m */,
B858897A128DF403002AC417 /* Foundation Additions */, B858897A128DF403002AC417 /* Foundation Additions */,
B8F5E67C12A02F6500E58C94 /* Unit Tests */, B8F5E67C12A02F6500E58C94 /* Unit Tests */,
); );
Expand Down Expand Up @@ -287,6 +293,7 @@
B8806A6912B3E88500F85BCE /* CWDebugUtilities.h in Headers */, B8806A6912B3E88500F85BCE /* CWDebugUtilities.h in Headers */,
B857FC7012B96275001AA9A9 /* NSObjectAdditions.h in Headers */, B857FC7012B96275001AA9A9 /* NSObjectAdditions.h in Headers */,
B857FD0F12BA8E46001AA9A9 /* CWFoundation.h in Headers */, B857FD0F12BA8E46001AA9A9 /* CWFoundation.h in Headers */,
B8E914CA12BFF5C000167AE8 /* CWPathUtilities.h in Headers */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
Expand Down Expand Up @@ -409,6 +416,7 @@
B8806A6A12B3E88500F85BCE /* CWDebugUtilities.m in Sources */, B8806A6A12B3E88500F85BCE /* CWDebugUtilities.m in Sources */,
B857FC7112B96275001AA9A9 /* NSObjectAdditions.m in Sources */, B857FC7112B96275001AA9A9 /* NSObjectAdditions.m in Sources */,
B857FD1012BA8E46001AA9A9 /* CWFoundation.m in Sources */, B857FD1012BA8E46001AA9A9 /* CWFoundation.m in Sources */,
B8E914CB12BFF5C000167AE8 /* CWPathUtilities.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
Expand Down
2 changes: 1 addition & 1 deletion Zangetsu_Prefix.pch
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@


#ifdef __OBJC__ #ifdef __OBJC__
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "CWMacros.h" #import "Zangetsu.h"
#endif #endif

0 comments on commit 7687e15

Please sign in to comment.