Mercurial > projects > dwt-mac
comparison dwt/program/Program.d @ 147:64712e72cb16
Fixes #32
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 07 Jun 2009 00:04:52 +0200 |
parents | 07399639c0c8 |
children |
comparison
equal
deleted
inserted
replaced
146:05e03d23ca3a | 147:64712e72cb16 |
---|---|
81 if (extension.length () is 0) return null; | 81 if (extension.length () is 0) return null; |
82 if (extension.charAt(0) !is '.') extension = "." ~ extension; | 82 if (extension.charAt(0) !is '.') extension = "." ~ extension; |
83 NSAutoreleasePool pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init(); | 83 NSAutoreleasePool pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init(); |
84 try { | 84 try { |
85 NSWorkspace workspace = NSWorkspace.sharedWorkspace(); | 85 NSWorkspace workspace = NSWorkspace.sharedWorkspace(); |
86 objc.id appName = cast(objc.id) OS.malloc(C.PTR_SIZEOF); | 86 objc.id appName = new objc.objc_object; |
87 objc.id type = cast(objc.id) OS.malloc(C.PTR_SIZEOF); | 87 objc.id type = new objc.objc_object; |
88 NSString temp = new NSString(OS.NSTemporaryDirectory()); | 88 NSString temp = new NSString(OS.NSTemporaryDirectory()); |
89 NSString fileName = NSString.stringWith("swt" ~ Format("{}", System.currentTimeMillis()) ~ extension); | 89 NSString fileName = NSString.stringWith("swt" ~ Format("{}", System.currentTimeMillis()) ~ extension); |
90 NSString fullPath = temp.stringByAppendingPathComponent(fileName); | 90 NSString fullPath = temp.stringByAppendingPathComponent(fileName); |
91 NSFileManager fileManager = NSFileManager.defaultManager(); | 91 NSFileManager fileManager = NSFileManager.defaultManager(); |
92 fileManager.createFileAtPath(fullPath, null, null); | 92 fileManager.createFileAtPath(fullPath, null, null); |
93 workspace.getInfoForFile(fullPath, appName, type); | 93 workspace.getInfoForFile(fullPath, appName, type); |
94 fileManager.removeItemAtPath(fullPath, null); | 94 fileManager.removeItemAtPath(fullPath, null); |
95 objc.id buffer; | 95 objc.id buffer = appName; |
96 OS.memmove(buffer, appName, C.PTR_SIZEOF); | |
97 OS.free(appName); | |
98 OS.free(type); | |
99 if (buffer !is null) { | 96 if (buffer !is null) { |
100 NSString appPath = new NSString(buffer); | 97 NSString appPath = new NSString(buffer); |
101 NSBundle bundle = NSBundle.bundleWithPath(appPath); | 98 NSBundle bundle = NSBundle.bundleWithPath(appPath); |
102 if (bundle !is null) return getProgram(bundle); | 99 if (bundle !is null) return getProgram(bundle); |
103 } | 100 } |