(+initialize) [PROCFS_EXE_LINK]: Make sure that the link is a path before using it.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16131 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Alexander Malmberg 2003-03-05 14:53:21 +00:00
parent b3b6911ff7
commit c64089723a
2 changed files with 18 additions and 0 deletions

View file

@ -1,3 +1,8 @@
2003-03-05 15:50 Alexander Malmberg <alexander@malmberg.org>
* Source/NSBundle.m (+initialize) [PROCFS_EXE_LINK]: Make sure that
the link is a path before using it.
2003-03-03 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/gnustep/base/objc-gnu2next.h: Added some trivial reverse

View file

@ -585,6 +585,19 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
_executable_path = [[NSFileManager defaultManager]
pathContentOfSymbolicLinkAtPath:
[NSString stringWithCString: PROCFS_EXE_LINK]];
/*
On some systems, the link is of the form "[device]:inode", which
can be used to open the executable, but is useless if you want
the path to it. Thus we check that the path is an actual absolute
path. (Using '/' here is safe; it isn't the path separator
everywhere, but it is on all systems that have PROCFS_EXE_LINK.)
*/
if ([_executable_path length] > 0 &&
[_executable_path characterAtIndex: 0] != '/')
{
_executable_path = nil;
}
#endif
if (_executable_path == nil || [_executable_path length] == 0)
{