Skip to content

Commit e2837c6

Browse files
committed
Code cleanup
1 parent a20be8a commit e2837c6

18 files changed

+138
-207
lines changed

English.lproj/InfoPlist.strings

10 Bytes
Binary file not shown.

Info.plist

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>2.6</string>
20+
<string>2.7</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>
24-
<string>6</string>
24+
<string>7</string>
2525
<key>LSApplicationCategoryType</key>
2626
<string>public.app-category.utilities</string>
2727
<key>LSMinimumSystemVersion</key>

LICENSE.md

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
cd to
2-
Copyright (C) 2007-2013 Jay Tuley
32

4-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3+
Copyright (c) 2007-2013 Jay Tuley
4+
Copyright (c) 2016 Evgeny Aleksandrov
55

6-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
712

8-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

cd_to.xcodeproj/project.pbxproj

-8
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,6 @@
226226
/* End PBXFrameworksBuildPhase section */
227227

228228
/* Begin PBXGroup section */
229-
080E96DDFE201D6D7F000001 /* Classes */ = {
230-
isa = PBXGroup;
231-
children = (
232-
);
233-
name = Classes;
234-
sourceTree = "<group>";
235-
};
236229
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = {
237230
isa = PBXGroup;
238231
children = (
@@ -266,7 +259,6 @@
266259
69C8AA70106E8F5800C4DE0D /* Finder.app */,
267260
69449AD50B8909AB00A19631 /* plugin */,
268261
694495BE0B869B3B00A19631 /* external projects */,
269-
080E96DDFE201D6D7F000001 /* Classes */,
270262
29B97315FDCFA39411CA2CEA /* Other Sources */,
271263
29B97317FDCFA39411CA2CEA /* Resources */,
272264
29B97323FDCFA39411CA2CEA /* Frameworks */,

main.m

+65-68
Original file line numberDiff line numberDiff line change
@@ -10,85 +10,82 @@
1010
#import "CD2PluginProtocolV1.h"
1111
#import "Finder.h"
1212

13-
NSString* getPathToFrontFinderWindow(){
14-
15-
FinderApplication* finder = [SBApplication applicationWithBundleIdentifier:@"com.apple.Finder"];
13+
NSString *getPathToFrontFinderWindow() {
1614

17-
FinderItem *target = [(NSArray*)[[finder selection]get] firstObject];
18-
if (target == nil){
15+
FinderApplication* finder = [SBApplication applicationWithBundleIdentifier:@"com.apple.Finder"];
16+
17+
FinderItem *target = [(NSArray*)[[finder selection]get] firstObject];
18+
if (target == nil) {
1919
target = [[[[finder FinderWindows] firstObject] target] get];
2020
}
21-
22-
NSURL* url =[NSURL URLWithString:target.URL];
23-
NSError* error;
24-
NSData* bookmark = [NSURL bookmarkDataWithContentsOfURL:url error:nil];
25-
NSURL* fullUrl = [NSURL URLByResolvingBookmarkData:bookmark
26-
options:NSURLBookmarkResolutionWithoutUI
27-
relativeToURL:nil
28-
bookmarkDataIsStale:nil
29-
error:&error];
30-
if(fullUrl != nil){
21+
22+
NSURL *url =[NSURL URLWithString:target.URL];
23+
NSError *error;
24+
NSData *bookmark = [NSURL bookmarkDataWithContentsOfURL:url error:nil];
25+
NSURL *fullUrl = [NSURL URLByResolvingBookmarkData:bookmark
26+
options:NSURLBookmarkResolutionWithoutUI
27+
relativeToURL:nil
28+
bookmarkDataIsStale:nil
29+
error:&error];
30+
if (fullUrl != nil) {
3131
url = fullUrl;
3232
}
33-
34-
35-
NSString* path = [[url path] stringByExpandingTildeInPath];
36-
33+
34+
35+
NSString* path = [[url path] stringByExpandingTildeInPath];
36+
3737
BOOL isDir = NO;
38-
[[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir];
39-
38+
[[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir];
4039

4140

42-
if(!isDir){
43-
path = [path stringByDeletingLastPathComponent];
44-
}
45-
46-
return path;
41+
42+
if (!isDir) {
43+
path = [path stringByDeletingLastPathComponent];
44+
}
45+
46+
return path;
4747
}
4848

49-
NSArray* loadPlugins(){
50-
NSString* pluginPath = [[NSBundle mainBundle] builtInPlugInsPath];
51-
NSArray* bundlePaths = [NSArray array];
52-
if (pluginPath != nil) {
53-
bundlePaths =[NSBundle pathsForResourcesOfType:@"bundle"
54-
inDirectory:pluginPath];
55-
}
56-
NSMutableArray* pluginObjectArrays = [NSMutableArray array];
57-
NSEnumerator *enumerator = [bundlePaths objectEnumerator];
58-
NSString* path;
59-
while ((path = (NSString*)[enumerator nextObject])) {
60-
NSBundle* bundle =[NSBundle bundleWithPath:path];
61-
Class pClass =[bundle principalClass];
62-
if([pClass conformsToProtocol:@protocol(CD2PluginProtocolV1)] && [pClass isKindOfClass:[NSObject class]]){
63-
[pluginObjectArrays addObject:[[[pClass alloc]init]autorelease]];
64-
}
65-
}
66-
67-
return pluginObjectArrays;
49+
NSArray *loadPlugins() {
50+
NSString *pluginPath = [[NSBundle mainBundle] builtInPlugInsPath];
51+
NSArray *bundlePaths = [NSArray array];
52+
if (pluginPath != nil) {
53+
bundlePaths =[NSBundle pathsForResourcesOfType:@"bundle"
54+
inDirectory:pluginPath];
55+
}
56+
NSMutableArray *pluginObjectArrays = [NSMutableArray array];
57+
NSEnumerator *enumerator = [bundlePaths objectEnumerator];
58+
NSString *path;
59+
while ((path = (NSString*)[enumerator nextObject])) {
60+
NSBundle* bundle =[NSBundle bundleWithPath:path];
61+
Class pClass =[bundle principalClass];
62+
if ([pClass conformsToProtocol:@protocol(CD2PluginProtocolV1)] && [pClass isKindOfClass:[NSObject class]]) {
63+
[pluginObjectArrays addObject:[[[pClass alloc]init]autorelease]];
64+
}
65+
}
66+
67+
return pluginObjectArrays;
6868
}
6969

70-
int main(int argc, char *argv[])
71-
{
72-
id pool = [[NSAutoreleasePool alloc] init];
73-
74-
NSString* path;
75-
@try{
76-
path = getPathToFrontFinderWindow();
77-
}@catch(id ex){
78-
path =[@"~/Desktop" stringByExpandingTildeInPath];
79-
}
80-
81-
NSArray* plugins =loadPlugins();
82-
83-
NSEnumerator *enumerator = [plugins objectEnumerator];
84-
id <CD2PluginProtocolV1> plugin;
85-
while ((plugin = (id <CD2PluginProtocolV1>)[enumerator nextObject])) {
86-
[plugin openTermWindowForPath:path];
87-
}
88-
89-
[pool release];
70+
int main(int argc, char *argv[]) {
71+
id pool = [[NSAutoreleasePool alloc] init];
72+
73+
NSString *path;
74+
@try {
75+
path = getPathToFrontFinderWindow();
76+
}
77+
@catch (id ex) {
78+
path =[@"~/Desktop" stringByExpandingTildeInPath];
79+
}
80+
81+
NSArray *plugins = loadPlugins();
82+
83+
NSEnumerator *enumerator = [plugins objectEnumerator];
84+
id <CD2PluginProtocolV1> plugin;
85+
while ((plugin = (id <CD2PluginProtocolV1>)[enumerator nextObject])) {
86+
[plugin openTermWindowForPath:path];
87+
}
88+
89+
[pool release];
9090
return 0;
9191
}
92-
93-
94-

plugins/X11_xterm/CD2X11XTermPlugin.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99
#import <Cocoa/Cocoa.h>
1010
#import "CD2PluginProtocolV1.h"
1111

12-
@interface CD2X11XTermPlugin : NSObject <CD2PluginProtocolV1> {
13-
14-
}
15-
16-
-(BOOL)openTermWindowForPath:(NSString*)aPath;
12+
@interface CD2X11XTermPlugin : NSObject <CD2PluginProtocolV1>
1713

14+
- (BOOL)openTermWindowForPath:(NSString *)aPath;
1815

1916
@end

plugins/X11_xterm/CD2X11XTermPlugin.m

+24-25
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,36 @@
88

99
#import "CD2X11XTermPlugin.h"
1010

11-
1211
@implementation CD2X11XTermPlugin
1312

14-
-(BOOL)openTermWindowForPath:(NSString*)aPath{
15-
@try{
16-
if(![[NSWorkspace sharedWorkspace] launchApplication:@"X11.app"]){
13+
- (BOOL)openTermWindowForPath:(NSString *)aPath{
14+
@try {
15+
if (![[NSWorkspace sharedWorkspace] launchApplication:@"X11.app"]) {
1716
[[NSWorkspace sharedWorkspace] launchApplication:@"XQuartz.app"];
1817
}
19-
NSTask* task =[[NSTask alloc]init];
20-
[task setCurrentDirectoryPath:aPath];
21-
NSMutableDictionary* enviornment =[[[[NSProcessInfo processInfo] environment] mutableCopy]autorelease];
22-
23-
[task setEnvironment:enviornment];
24-
25-
NSString* path = @"/usr/X11R6/bin/xterm";
26-
if(![[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:NULL]){
18+
19+
NSTask *task = [[NSTask alloc] init];
20+
[task setCurrentDirectoryPath:aPath];
21+
22+
NSMutableDictionary *enviornment = [[[[NSProcessInfo processInfo] environment] mutableCopy] autorelease];
23+
[task setEnvironment:enviornment];
24+
25+
NSString *path = @"/usr/X11R6/bin/xterm";
26+
if (![[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:NULL]) {
2727
path = @"/opt/X11/bin/xterm";
2828
}
29-
[task setLaunchPath:path];
30-
31-
[task setStandardOutput:[NSFileHandle fileHandleWithStandardOutput]];
32-
33-
[task setStandardError:[NSFileHandle fileHandleWithStandardOutput]];
34-
[task launch];
35-
36-
}
37-
@catch(id ex){
38-
return NO;
39-
}
40-
41-
return YES;
29+
[task setLaunchPath:path];
30+
31+
[task setStandardOutput:[NSFileHandle fileHandleWithStandardOutput]];
32+
[task setStandardError:[NSFileHandle fileHandleWithStandardOutput]];
33+
34+
[task launch];
35+
}
36+
@catch (id ex) {
37+
return NO;
38+
}
39+
40+
return YES;
4241
}
4342

4443
@end
-16 Bytes
Binary file not shown.

plugins/X11_xterm/X11_xterm.xcodeproj/project.pbxproj

-12
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
1919
089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
2020
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
21-
32DBCF630370AF2F00C91783 /* X11_xterm_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = X11_xterm_Prefix.pch; sourceTree = "<group>"; };
2221
69449BBF0B8925F900A19631 /* CD2X11XTermPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CD2X11XTermPlugin.h; sourceTree = "<group>"; };
2322
69449BC00B8925F900A19631 /* CD2X11XTermPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CD2X11XTermPlugin.m; sourceTree = "<group>"; };
2423
69449BC50B89260700A19631 /* CD2PluginProtocolV1.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CD2PluginProtocolV1.h; path = ../CD2PluginProtocolV1.h; sourceTree = SOURCE_ROOT; };
@@ -45,7 +44,6 @@
4544
children = (
4645
69449BC50B89260700A19631 /* CD2PluginProtocolV1.h */,
4746
08FB77AFFE84173DC02AAC07 /* Classes */,
48-
32C88E010371C26100C91783 /* Other Sources */,
4947
089C167CFE841241C02AAC07 /* Resources */,
5048
089C1671FE841209C02AAC07 /* Frameworks and Libraries */,
5149
19C28FB8FE9D52D311CA2CBB /* Products */,
@@ -107,14 +105,6 @@
107105
name = Products;
108106
sourceTree = "<group>";
109107
};
110-
32C88E010371C26100C91783 /* Other Sources */ = {
111-
isa = PBXGroup;
112-
children = (
113-
32DBCF630370AF2F00C91783 /* X11_xterm_Prefix.pch */,
114-
);
115-
name = "Other Sources";
116-
sourceTree = "<group>";
117-
};
118108
/* End PBXGroup section */
119109

120110
/* Begin PBXNativeTarget section */
@@ -212,7 +202,6 @@
212202
GCC_MODEL_TUNING = G5;
213203
GCC_OPTIMIZATION_LEVEL = 0;
214204
GCC_PRECOMPILE_PREFIX_HEADER = YES;
215-
GCC_PREFIX_HEADER = X11_xterm_Prefix.pch;
216205
INFOPLIST_FILE = Info.plist;
217206
INSTALL_PATH = /unsigned/plugins;
218207
PRODUCT_BUNDLE_IDENTIFIER = indy.jt.cdto.plugin.x11xterm;
@@ -231,7 +220,6 @@
231220
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
232221
GCC_MODEL_TUNING = G5;
233222
GCC_PRECOMPILE_PREFIX_HEADER = YES;
234-
GCC_PREFIX_HEADER = X11_xterm_Prefix.pch;
235223
INFOPLIST_FILE = Info.plist;
236224
INSTALL_PATH = /unsigned/plugins;
237225
PRODUCT_BUNDLE_IDENTIFIER = indy.jt.cdto.plugin.x11xterm;

plugins/X11_xterm/X11_xterm_Prefix.pch

-7
This file was deleted.

plugins/iterm/CD2ITerm.h

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
// iterm
44
//
55
// Created by James Tuley on 2/18/07.
6-
// Copyright 2007 __MyCompanyName__. All rights reserved.
6+
// Copyright 2007 Jay Tuley. All rights reserved.
77
//
88

99
#import <Cocoa/Cocoa.h>
1010
#import "CD2PluginProtocolV1.h"
1111

12-
@interface CD2ITerm : NSObject<CD2PluginProtocolV1> {
12+
@interface CD2ITerm : NSObject<CD2PluginProtocolV1>
1313

14-
}
15-
16-
-(BOOL)openTermWindowForPath:(NSString*)aPath;
14+
- (BOOL)openTermWindowForPath:(NSString *)aPath;
1715

1816
@end

plugins/iterm/CD2ITerm.m

+11-9
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,22 @@
99
#import "CD2ITerm.h"
1010

1111
@implementation CD2ITerm
12-
-(BOOL)openTermWindowForPath:(NSString*)aPath{
13-
@try{
12+
13+
- (BOOL)openTermWindowForPath:(NSString *)aPath {
14+
@try {
1415
NSString *iterm2AbsolutePath;
1516
iterm2AbsolutePath = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:@"com.googlecode.iterm2"];
16-
17-
if (iterm2AbsolutePath)
17+
18+
if (iterm2AbsolutePath) {
1819
[[NSWorkspace sharedWorkspace] openFile:[aPath stringByExpandingTildeInPath]
1920
withApplication:iterm2AbsolutePath
2021
andDeactivate:YES];
21-
22-
}@catch(id test){
23-
return NO;
24-
}
25-
return YES;
22+
}
23+
24+
} @catch (id test) {
25+
return NO;
26+
}
27+
return YES;
2628
}
2729

2830
@end

0 commit comments

Comments
 (0)