Fix standardizing absolute paths: first check for them, then add CWD

then standardize the path.
As we are, add a nil/empty string check for path.
This commit is contained in:
Riccardo Mottola 2025-04-02 01:46:40 +02:00
parent e3da52aae3
commit a4da1a1b5a

View file

@ -1,9 +1,10 @@
/* This tool opens the appropriate application from the command line
based on what type of file is being accessed.
Copyright (C) 2001 Free Software Foundation, Inc.
Copyright (C) 2001-2025 Software Foundation, Inc.
Written by: Gregory Casamento <greg_casamento@yahoo.com>
Written by: Gregory Casamento <greg.casamento@gmail.com>
Riccardo Mottola <rm@gnu.org>
Created: November 2001
This file is part of the GNUstep Project
@ -45,11 +46,12 @@
static NSString*
absolutePath(NSFileManager *fm, NSString *path)
{
if (nil == path || [path length] == 0)
return path;
if (![path isAbsolutePath])
path = [[fm currentDirectoryPath] stringByAppendingPathComponent: path] ;
path = [path stringByStandardizingPath];
if ([path isAbsolutePath] == NO)
{
path = [[fm currentDirectoryPath] stringByAppendingPathComponent: path];
}
return path;
}