discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNUstep "open" tool


From: Jeff Teunissen
Subject: Re: GNUstep "open" tool
Date: Thu, 22 Nov 2001 03:17:53 -0500

Gregory Casamento wrote:
> 
> I committed this to the repository.   The tool is called "gopen" and is
> in the gui/Tools directory.  Just a few notes on it:
> 
> 1) You must have installed the applications into the appropriate
> "well-known" locations for this to work when opening a file.  When
> make_services scans all of the applications it builds a plist called
> .GNUstepAppList in the ~/GNUstep/Services directory.
> 
> 2) The application must declare which files it handles in it's
> Info-gnustep.plist (under Resources in the app wrapper) file since this
> is what make_services uses to build the file mentioned above.
> 
> I have tested this with Gorm.app, Ink.app and ImageViewer.app and it
> seems to work very well.
> 
> Please let me know if there are any issues.

I just patched gopen locally, to make it search the well-known paths for apps,
like *step "open" does. It's attached to this message, if you'd like to
include it or something similar into the standard gopen.

[snip]

-- 
| Jeff Teunissen  -=-  Pres., Dusk To Dawn Computing  -=-  deek @ d2dc.net
| GPG: 1024D/9840105A   7102 808A 7733 C2F3 097B  161B 9222 DAB8 9840 105A
| Core developer, The QuakeForge Project        http://www.quakeforge.net/
| Specializing in Debian GNU/Linux              http://www.d2dc.net/~deek/
Index: gopen.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/gui/Tools/gopen.m,v
retrieving revision 1.1
diff -u -r1.1 gopen.m
--- gopen.m     2001/11/18 19:01:07     1.1
+++ gopen.m     2001/11/22 08:12:36
@@ -27,6 +27,8 @@
 #include <Foundation/NSTask.h>
 #include <Foundation/NSAutoreleasePool.h>
 #include <Foundation/NSException.h>
+#include <Foundation/NSPathUtilities.h>
+#include <Foundation/NSFileManager.h>
 #include <AppKit/NSApplication.h>
 #include <AppKit/NSWorkspace.h>
 
@@ -72,14 +74,31 @@
          {
            if( [ext isEqualToString: @"app"] )
              {
+               NSFileManager *fm = [NSFileManager defaultManager];
                NSString *appName = 
                  [[file lastPathComponent] stringByDeletingPathExtension];
                NSString *executable = 
                  [file stringByAppendingPathComponent: appName];
-               NSTask *task = nil;
-
-               if ([NSTask launchedTaskWithLaunchPath: executable arguments: 
nil] == nil)
-                 printf("Unable to launch application at path %s.\n",[file 
cString]);
+               
+               if ( [fm fileExistsAtPath: executable] )
+                 {
+                   if ( ![NSTask launchedTaskWithLaunchPath: executable 
arguments: nil] )
+                     printf("Unable to launch application at path %s.\n",[file 
cString]);
+                 }
+               else
+                 {
+                   NSString *fullPath;
+                   NSEnumerator *pathEnumerator = 
+                     
[NSSearchPathForDirectoriesInDomains(NSApplicationDirectory, NSAllDomainsMask, 
YES) objectEnumerator];
+                   
+                   while ((fullPath = [pathEnumerator nextObject]))
+                     {
+                       if ( ![fm fileExistsAtPath: [fullPath 
stringByAppendingPathComponent: file]] )
+                         continue;
+                       [NSTask launchedTaskWithLaunchPath: [fullPath 
stringByAppendingPathComponent: executable] arguments: nil];
+                       break;
+                     }
+                 }
              }
            else
              {

reply via email to

[Prev in Thread] Current Thread [Next in Thread]