discuss-gnustep
[Top][All Lists]
Advanced

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

+[NSBundle mainBundle] broken for tools?


From: Roland Schwingel
Subject: +[NSBundle mainBundle] broken for tools?
Date: Mon, 21 Jul 2003 14:20:52 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) Gecko/20030312

Hi...

If one wants to run a tool and +[NSBundle mainBundle] is called it will run into serious trouble...

Imagine you have a tool which fullpath is
/imagine/your/favourite/path/tool

+[NSBundle mainBundle] first generates
toolName = tool
path = /imagine/your/favourite/path

Afterwards it checks path for having a .app/.debug etc suffix. When this suffix is not present (look above) the tool is declared to be a non-application (isApplication = NO). And now the bug happens.

   if (isApplication == NO)
   {
     path = [path stringByAppendingPathComponent: @"Resources"];
     path = [path stringByAppendingPathComponent: toolName];
    }

So path is now: /imagine/your/favourite/path/Resources/tool which is then used for [_mainBundle initWithPath:path] which fails.... So if you have a standalone tool, do you really need this directory-structure for it??? It looks a bit odd to me....

To get my tools working I commented out the if() shown above and everything is fine now for me...
The attached patch does this as well....

Roland

--- NSBundle.m.orig     2003-07-21 14:19:47.000000000 +0200
+++ NSBundle.m  2003-07-21 14:20:00.000000000 +0200
@@ -830,12 +830,12 @@
              isApplication = NO;
            }
        }
-      
+      /*
       if (isApplication == NO)
        {
          path = [path stringByAppendingPathComponent: @"Resources"];
          path = [path stringByAppendingPathComponent: toolName];
-       }
+       }*/
 
       NSDebugMLLog(@"NSBundle", @"Found main in address@hidden", path);
       /* We do alloc and init separately so initWithPath: knows we are

reply via email to

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